// Copyright 2017-2025 WIT.COM Inc. All rights reserved. // Use of this source code is governed by the GPL 3.0 package main import ( "embed" "os" "time" "go.wit.com/dev/alexflint/arg" "go.wit.com/lib/protobuf/zoopb" "go.wit.com/log" ) var VERSION string var BUILDTIME string //go:embed resources/* var resources embed.FS func main() { me = new(zoodStruct) me.pp = arg.MustParse(&argv) if me.pp == nil { me.pp.WriteHelp(os.Stdout) os.Exit(0) } if argv.Daemon { // turn off timestamps for STDOUT (systemd adds them) log.DaemonMode(true) me.machine, me.fullpath = zoopb.InitDaemon() } else { me.machine, me.fullpath = zoopb.InitMachine() } me.urlbase = "http://zookeeper.chap.wit.com:8080" if argv.URL != "" { log.Info("USING ARGV URL:", argv.URL) me.urlbase = argv.URL } me.pollDelay = 3 * time.Second me.failcountmax = 20 // die every minute if zookeeper can't be found 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 }