refactor connectors for retry logic, add error view

This commit is contained in:
Bradley Cicenas
2019-05-22 16:58:55 +00:00
parent 42f095cd85
commit 98fcfe8b6f
10 changed files with 284 additions and 72 deletions

17
main.go
View File

@@ -22,11 +22,12 @@ var (
version = "dev-build"
goVersion = runtime.Version()
log *logging.CTopLogger
cursor *GridCursor
cGrid *compact.CompactGrid
header *widgets.CTopHeader
status *widgets.StatusLine
log *logging.CTopLogger
cursor *GridCursor
cGrid *compact.CompactGrid
header *widgets.CTopHeader
status *widgets.StatusLine
errView *widgets.ErrorView
versionStr = fmt.Sprintf("ctop version %v, build %v %v", version, build, goVersion)
)
@@ -104,14 +105,15 @@ func main() {
defer Shutdown()
// init grid, cursor, header
conn, err := connector.ByName(*connectorFlag)
cSuper, err := connector.ByName(*connectorFlag)
if err != nil {
panic(err)
}
cursor = &GridCursor{cSource: conn}
cursor = &GridCursor{cSuper: cSuper}
cGrid = compact.NewCompactGrid()
header = widgets.NewCTopHeader()
status = widgets.NewStatusLine()
errView = widgets.NewErrorView()
for {
exit := Display()
@@ -140,6 +142,7 @@ func validSort(s string) {
func panicExit() {
if r := recover(); r != nil {
Shutdown()
panic(r)
fmt.Printf("error: %s\n", r)
os.Exit(1)
}