2016-12-22 23:04:21 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-03-03 08:57:26 +01:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2017-02-07 04:33:09 +01:00
|
|
|
"github.com/bcicen/ctop/config"
|
2017-03-06 04:03:05 +01:00
|
|
|
"github.com/bcicen/ctop/cwidgets/compact"
|
2017-02-04 03:01:52 +01:00
|
|
|
"github.com/bcicen/ctop/logging"
|
2017-03-06 04:03:05 +01:00
|
|
|
"github.com/bcicen/ctop/widgets"
|
2017-01-01 23:48:35 +01:00
|
|
|
ui "github.com/gizak/termui"
|
2016-12-22 23:04:21 +01:00
|
|
|
)
|
|
|
|
|
2017-03-06 04:03:05 +01:00
|
|
|
var (
|
2017-03-07 01:13:48 +01:00
|
|
|
build = ""
|
|
|
|
version = "dev-build"
|
|
|
|
|
2017-03-06 04:03:05 +01:00
|
|
|
log *logging.CTopLogger
|
|
|
|
cursor *GridCursor
|
|
|
|
cGrid = compact.NewCompactGrid()
|
|
|
|
header = widgets.NewCTopHeader()
|
|
|
|
)
|
2017-02-04 03:01:52 +01:00
|
|
|
|
2016-12-26 00:05:22 +01:00
|
|
|
func main() {
|
2017-03-03 08:57:26 +01:00
|
|
|
defer func() {
|
|
|
|
if r := recover(); r != nil {
|
|
|
|
ui.Clear()
|
2017-03-07 01:09:46 +01:00
|
|
|
fmt.Printf("panic: %s\n", r)
|
2017-03-03 08:57:26 +01:00
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}()
|
2017-03-06 04:03:05 +01:00
|
|
|
|
2017-02-16 04:49:41 +01:00
|
|
|
config.Init()
|
2017-03-07 01:09:46 +01:00
|
|
|
|
|
|
|
// init logger
|
2017-02-12 06:14:50 +01:00
|
|
|
log = logging.Init()
|
2017-02-16 05:06:05 +01:00
|
|
|
if config.GetSwitchVal("loggingEnabled") {
|
2017-02-17 07:48:38 +01:00
|
|
|
logging.StartServer()
|
2017-02-12 06:14:50 +01:00
|
|
|
}
|
2017-03-07 01:09:46 +01:00
|
|
|
|
|
|
|
// init ui, grid
|
2017-01-01 23:48:35 +01:00
|
|
|
if err := ui.Init(); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer ui.Close()
|
2017-03-07 01:09:46 +01:00
|
|
|
cursor = NewGridCursor()
|
2017-01-03 18:37:09 +01:00
|
|
|
|
2017-01-01 23:42:13 +01:00
|
|
|
for {
|
2017-03-06 04:03:05 +01:00
|
|
|
exit := Display()
|
2017-01-01 23:42:13 +01:00
|
|
|
if exit {
|
2017-02-05 01:25:30 +01:00
|
|
|
log.Notice("shutting down")
|
|
|
|
log.Exit()
|
2017-01-01 23:48:35 +01:00
|
|
|
return
|
2017-01-01 23:42:13 +01:00
|
|
|
}
|
2016-12-22 23:04:21 +01:00
|
|
|
}
|
|
|
|
}
|