diff --git a/Makefile b/Makefile index c1d19ae..a968c71 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,8 @@ gocui: build ./zookeeper --gui gocui gocui-debugging: build - ./zookeeper --gui gocui --gui-file ~/go/src/go.wit.com/toolkits/gocui/gocui.so >/tmp/forge.log 2>&1 + ./zookeeper --gui gocui --gui-file ~/go/src/go.wit.com/toolkits/gocui/gocui.so + # ./zookeeper --gui gocui --gui-file ~/go/src/go.wit.com/toolkits/gocui/gocui.so >/tmp/forge.log 2>&1 build: goimports vet GO111MODULE=off go build -v -x \ diff --git a/argv.go b/argv.go index 39e206f..945ff6a 100644 --- a/argv.go +++ b/argv.go @@ -18,6 +18,7 @@ type args struct { Verbose bool `arg:"--verbose" default:"false" help:"talk more"` Daemon bool `arg:"--daemon" default:"false" help:"run in daemon mode"` Port int `arg:"--port" default:"8080" help:"port to run on"` + NoPort bool `arg:"--no-port" help:"don't open socket"` } func (args) Version() string { diff --git a/http.go b/http.go index f0b5e07..7711300 100644 --- a/http.go +++ b/http.go @@ -75,7 +75,7 @@ func startHTTP() { http.HandleFunc("/", okHandler) p := fmt.Sprintf(":%d", argv.Port) - log.Println("Running on port", p) + log.Println("zookeeper main startHTTP() Running on port", p) err := http.ListenAndServe(p, nil) if err != nil { diff --git a/main.go b/main.go index c4467fc..f8a0fb1 100644 --- a/main.go +++ b/main.go @@ -21,15 +21,27 @@ var BUILDTIME string var resources embed.FS func main() { + log.Warn("zookeeper PID:", os.Getpid(), os.Args) var pp *arg.Parser - gui.InitArg() - pp = arg.MustParse(&argv) + gui.InitArg() // include the 'gui' package command line arguements + pp = arg.MustParse(&argv) // parse the command line if pp == nil { pp.WriteHelp(os.Stdout) os.Exit(0) } + // check if the binary is being called to test + // if the plugin can actually loaded. This is a hack + // around needing a Test() plugin load function in GO + if gui.IsGoPluginTestHack() { + argv.NoPort = true + gui.CheckPlugin() + os.Exit(0) + // if argv.GuiCheck != "" { + // } + } + if argv.Daemon { // turn off timestamps for STDOUT (systemd adds them) log.DaemonMode(true) @@ -45,9 +57,11 @@ func main() { } // me.upgrade = make(map[string]bool) // used to trigger upgrade attempts + // log.Sleep(3) + go NewWatchdog() - - go startHTTP() - + if !argv.NoPort { + go startHTTP() + } doGui() }