minor fixes
This commit is contained in:
parent
3a786d60fd
commit
7f20ecc438
15
main.go
15
main.go
|
@ -20,20 +20,23 @@ var BUILDTIME string
|
||||||
var resources embed.FS
|
var resources embed.FS
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var pp *arg.Parser
|
me = new(zoodStruct)
|
||||||
pp = arg.MustParse(&argv)
|
me.pp = arg.MustParse(&argv)
|
||||||
|
|
||||||
if pp == nil {
|
if me.pp == nil {
|
||||||
pp.WriteHelp(os.Stdout)
|
me.pp.WriteHelp(os.Stdout)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.Daemon {
|
if argv.Daemon {
|
||||||
// turn off timestamps for STDOUT (systemd adds them)
|
// turn off timestamps for STDOUT (systemd adds them)
|
||||||
log.DaemonMode(true)
|
log.DaemonMode(true)
|
||||||
|
me.machine, me.fullpath = zoopb.InitDaemon()
|
||||||
|
} else {
|
||||||
|
me.machine, me.fullpath = zoopb.InitMachine()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
me = new(stuff)
|
|
||||||
me.urlbase = "http://zookeeper.chap.wit.com:8080"
|
me.urlbase = "http://zookeeper.chap.wit.com:8080"
|
||||||
if argv.URL != "" {
|
if argv.URL != "" {
|
||||||
log.Info("USING ARGV URL:", argv.URL)
|
log.Info("USING ARGV URL:", argv.URL)
|
||||||
|
@ -43,8 +46,6 @@ func main() {
|
||||||
me.pollDelay = 3 * time.Second
|
me.pollDelay = 3 * time.Second
|
||||||
me.failcountmax = 20 // die every minute if zookeeper can't be found
|
me.failcountmax = 20 // die every minute if zookeeper can't be found
|
||||||
|
|
||||||
me.machine = zoopb.InitMachine()
|
|
||||||
|
|
||||||
if argv.Test != nil {
|
if argv.Test != nil {
|
||||||
testURL(me.urlbase, me.machine)
|
testURL(me.urlbase, me.machine)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|
|
@ -6,13 +6,14 @@ package main
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.wit.com/dev/alexflint/arg"
|
||||||
"go.wit.com/lib/protobuf/zoopb"
|
"go.wit.com/lib/protobuf/zoopb"
|
||||||
)
|
)
|
||||||
|
|
||||||
var me *stuff
|
var me *zoodStruct
|
||||||
|
|
||||||
// this app's variables
|
// this app's variables
|
||||||
type stuff struct {
|
type zoodStruct struct {
|
||||||
urlbase string // the dns name for the zookeeper
|
urlbase string // the dns name for the zookeeper
|
||||||
hostname string // my hostname
|
hostname string // my hostname
|
||||||
pollDelay time.Duration // how often to report our status
|
pollDelay time.Duration // how often to report our status
|
||||||
|
@ -20,4 +21,6 @@ type stuff struct {
|
||||||
machine *zoopb.Machine // populated from protobuf based zoopb
|
machine *zoopb.Machine // populated from protobuf based zoopb
|
||||||
failcount int // how many times we've failed to contact the zookeeper
|
failcount int // how many times we've failed to contact the zookeeper
|
||||||
failcountmax int // after this, exit and let systemd restart the daemon
|
failcountmax int // after this, exit and let systemd restart the daemon
|
||||||
|
fullpath string // where to save the machine PB file
|
||||||
|
pp *arg.Parser // from go-args
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue