diff --git a/Makefile b/Makefile index 636eafb..fd94d4e 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ REDOMOD = $(shell if [ -e go.sum ]; then echo go.sum exists; else GO111MODULE= all: build ./zood --version - ./zood + ./zood test build: goimports GO111MODULE=off go build -v -x \ diff --git a/README b/README index c9c8ffe..55ecd7e 100644 --- a/README +++ b/README @@ -1 +1,3 @@ This is the zookeeper daemon. + +It is simple. It's just designed to keep packages up to date. diff --git a/argv.go b/argv.go index 101fab8..0efa3c9 100644 --- a/argv.go +++ b/argv.go @@ -16,9 +16,13 @@ import ( var argv args type args struct { - Daemon bool `arg:"--daemon" default:"false" help:"run in daemon mode"` - Port int `arg:"--port" default:"2521" help:"port to run on"` - URL string `arg:"--url" help:"url to use"` + Test *EmptyCmd `arg:"subcommand:test" help:"New to forge? This is for you.'"` + Daemon bool `arg:"--daemon" default:"false" help:"run in daemon mode"` + Port int `arg:"--port" default:"2521" help:"port to run on"` + URL string `arg:"--url" help:"url to use"` +} + +type EmptyCmd struct { } func (args) Version() string { diff --git a/watchdog.go b/daemon.go similarity index 96% rename from watchdog.go rename to daemon.go index d9491b9..f92907f 100644 --- a/watchdog.go +++ b/daemon.go @@ -16,6 +16,7 @@ func TimeFunction(f func()) time.Duration { return time.Since(startTime) // Calculate the elapsed time } +// sends updates to zookeeper func zood() { me.dog = time.NewTicker(me.pollDelay) defer me.dog.Stop() diff --git a/main.go b/main.go index 3f685dd..581ef09 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,7 @@ func main() { } me = new(stuff) - me.urlbase = "http://zookeeper.grid.wit.com:8080" + me.urlbase = "http://zookeeper.chap.wit.com:8080" if argv.URL != "" { log.Info("USING ARGV URL:", argv.URL) me.urlbase = argv.URL @@ -45,5 +45,22 @@ func main() { me.machine = zoopb.InitMachine() + if argv.Test != nil { + testURL(me.urlbase, me.machine) + os.Exit(0) + } + zood() // talks to zookeeper } + +func testURL(urlbase string, pb *zoopb.Machine) error { + newpb, wsPB, err := pb.HttpPost(urlbase, "test") + if err != nil { + log.Info("got error:", err) + return err + } + wsPB.DumpClient() + newpb.Dump() + log.Info("got error:", err) + return err +}