59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
|
// Use of this source code is governed by the GPL 3.0
|
|
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"time"
|
|
|
|
"go.wit.com/dev/alexflint/arg"
|
|
"go.wit.com/lib/gui/prep"
|
|
"go.wit.com/lib/protobuf/httppb"
|
|
"go.wit.com/lib/protobuf/zoopb"
|
|
"go.wit.com/log"
|
|
)
|
|
|
|
var VERSION string
|
|
var BUILDTIME string
|
|
|
|
var ARGNAME string = "zookeeper"
|
|
|
|
func main() {
|
|
me = new(mainType)
|
|
prep.Bash(ARGNAME, argv.DoAutoComplete) // this line should be: prep.Bash(argv)
|
|
me.myGui = prep.Gui() // prepares the GUI package for go-args
|
|
me.pp = arg.MustParse(&argv)
|
|
|
|
if argv.Daemon {
|
|
// turn off timestamps for STDOUT (systemd adds them)
|
|
log.DaemonMode(true)
|
|
}
|
|
|
|
me.hostname, _ = os.Hostname()
|
|
me.pollDelay = time.Hour
|
|
me.machines = zoopb.NewMachines()
|
|
if err := me.machines.ConfigLoad(); err != nil {
|
|
log.Warn("load config failed", err)
|
|
os.Exit(-1)
|
|
}
|
|
if argv.List != nil {
|
|
log.Info("do list here")
|
|
okExit("")
|
|
}
|
|
|
|
go NewWatchdog()
|
|
if !argv.NoPort {
|
|
go httppb.StartHTTP(okHandler, argv.Port)
|
|
}
|
|
|
|
me.myGui.Start() // loads the GUI toolkit
|
|
doGui() // start making our forge GUI
|
|
|
|
// sit here forever refreshing the GUI
|
|
for {
|
|
refresh()
|
|
time.Sleep(90 * time.Second)
|
|
}
|
|
}
|