summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-22 16:34:57 -0500
committerJeff Carr <[email protected]>2025-09-22 16:34:57 -0500
commit7f20ecc4387f9d88b0645c73ac84c0723028470d (patch)
treeda7a0bdf343fee8081e7da385da7eaa924240254
parent3a786d60fd86802fc6e3fa2f0cc12c02a1751e85 (diff)
minor fixesv0.0.94
-rw-r--r--main.go15
-rw-r--r--structs.go7
2 files changed, 13 insertions, 9 deletions
diff --git a/main.go b/main.go
index 581ef09..047f416 100644
--- a/main.go
+++ b/main.go
@@ -20,20 +20,23 @@ var BUILDTIME string
var resources embed.FS
func main() {
- var pp *arg.Parser
- pp = arg.MustParse(&argv)
+ me = new(zoodStruct)
+ me.pp = arg.MustParse(&argv)
- if pp == nil {
- pp.WriteHelp(os.Stdout)
+ 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 = new(stuff)
me.urlbase = "http://zookeeper.chap.wit.com:8080"
if argv.URL != "" {
log.Info("USING ARGV URL:", argv.URL)
@@ -43,8 +46,6 @@ func main() {
me.pollDelay = 3 * time.Second
me.failcountmax = 20 // die every minute if zookeeper can't be found
- me.machine = zoopb.InitMachine()
-
if argv.Test != nil {
testURL(me.urlbase, me.machine)
os.Exit(0)
diff --git a/structs.go b/structs.go
index 802a5a7..4e3d500 100644
--- a/structs.go
+++ b/structs.go
@@ -6,13 +6,14 @@ package main
import (
"time"
+ "go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/protobuf/zoopb"
)
-var me *stuff
+var me *zoodStruct
// this app's variables
-type stuff struct {
+type zoodStruct struct {
urlbase string // the dns name for the zookeeper
hostname string // my hostname
pollDelay time.Duration // how often to report our status
@@ -20,4 +21,6 @@ type stuff struct {
machine *zoopb.Machine // populated from protobuf based zoopb
failcount int // how many times we've failed to contact the zookeeper
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
}