2016-12-22 22:04:21 +00:00
|
|
|
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"
|
2017-02-04 02:01:52 +00:00
|
|
|
"github.com/bcicen/ctop/logging"
|
2017-01-01 22:48:35 +00:00
|
|
|
ui "github.com/gizak/termui"
|
2016-12-22 22:04:21 +00:00
|
|
|
)
|
|
|
|
|
2017-02-12 05:10:40 +00:00
|
|
|
var log *logging.CTopLogger
|
2017-02-04 02:01:52 +00:00
|
|
|
|
2016-12-25 23:05:22 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}()
|
2017-02-16 03:49:41 +00:00
|
|
|
config.Init()
|
2017-02-12 05:14:50 +00:00
|
|
|
log = logging.Init()
|
2017-02-16 04:06:05 +00:00
|
|
|
if config.GetSwitchVal("loggingEnabled") {
|
2017-02-17 06:48:38 +00:00
|
|
|
logging.StartServer()
|
2017-02-12 05:14:50 +00:00
|
|
|
}
|
2017-01-01 22:48:35 +00:00
|
|
|
if err := ui.Init(); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer ui.Close()
|
2017-01-03 17:37:09 +00:00
|
|
|
|
2016-12-30 21:14:07 +00:00
|
|
|
g := NewGrid()
|
2017-01-01 22:42:13 +00:00
|
|
|
for {
|
|
|
|
exit := Display(g)
|
|
|
|
if exit {
|
2017-02-05 00:25:30 +00:00
|
|
|
log.Notice("shutting down")
|
|
|
|
log.Exit()
|
2017-01-01 22:48:35 +00:00
|
|
|
return
|
2017-01-01 22:42:13 +00:00
|
|
|
}
|
2016-12-22 22:04:21 +00:00
|
|
|
}
|
|
|
|
}
|