ctop/main.go

50 lines
777 B
Go
Raw Normal View History

package main
import (
2017-03-03 07:57:26 +00:00
"fmt"
"os"
2017-02-07 03:33:09 +00:00
"github.com/bcicen/ctop/config"
"github.com/bcicen/ctop/cwidgets/compact"
"github.com/bcicen/ctop/logging"
"github.com/bcicen/ctop/widgets"
ui "github.com/gizak/termui"
)
var (
log *logging.CTopLogger
cursor *GridCursor
cGrid = compact.NewCompactGrid()
header = widgets.NewCTopHeader()
)
func main() {
2017-03-03 07:57:26 +00:00
defer func() {
if r := recover(); r != nil {
ui.Clear()
fmt.Printf("panic: %s", r)
os.Exit(1)
}
}()
config.Init()
log = logging.Init()
if config.GetSwitchVal("loggingEnabled") {
logging.StartServer()
}
cursor = NewGridCursor()
if err := ui.Init(); err != nil {
panic(err)
}
defer ui.Close()
2017-01-03 17:37:09 +00:00
for {
exit := Display()
if exit {
log.Notice("shutting down")
log.Exit()
return
}
}
}