fixes base on new package libraries

This commit is contained in:
Jeff Carr 2025-02-22 07:17:28 -06:00
parent 2152a6477f
commit 58ad49600a
4 changed files with 14 additions and 12 deletions

View File

@ -10,6 +10,7 @@ import (
"go.wit.com/dev/alexflint/arg" "go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/zoopb"
"go.wit.com/log" "go.wit.com/log"
) )
@ -46,7 +47,7 @@ func main() {
// me.machine.ConfigLoad() // me.machine.ConfigLoad()
me.forge = forgepb.InitPB() me.forge = forgepb.InitPB()
me.forge.InitMachine() me.machine = zoopb.InitMachine()
go NewWatchdog() go NewWatchdog()

10
send.go
View File

@ -13,9 +13,9 @@ import (
func pingStatus() error { func pingStatus() error {
var url string var url string
url = me.urlbase + "/status?hostname=" + me.forge.Machine.Hostname url = me.urlbase + "/status?hostname=" + me.machine.Hostname
/* /*
msg, err := me.forge.Machine.Packages.Marshal() msg, err := me.machine.Packages.Marshal()
if err != nil { if err != nil {
log.Info("proto.Marshal() failed:", err) log.Info("proto.Marshal() failed:", err)
return err return err
@ -23,7 +23,7 @@ func pingStatus() error {
log.Info("proto Marshal len =", len(msg)) log.Info("proto Marshal len =", len(msg))
*/ */
body, err := me.forge.HttpPostMachine(url) body, err := me.machine.HttpPostMachine(url)
if err != nil { if err != nil {
log.Info("httpPost() failed:", err) log.Info("httpPost() failed:", err)
return err return err
@ -45,7 +45,7 @@ func pingStatus() error {
func sendMachine(s string) error { func sendMachine(s string) error {
var url string var url string
url = me.urlbase + "/machine" url = me.urlbase + "/machine"
body, err := me.forge.HttpPostMachine(url) body, err := me.machine.HttpPostMachine(url)
if err != nil { if err != nil {
log.Info("httpPost() failed: url", url) log.Info("httpPost() failed: url", url)
log.Info("httpPost() failed:", err) log.Info("httpPost() failed:", err)
@ -71,7 +71,7 @@ func sendMachine(s string) error {
os.Exit(0) os.Exit(0)
} else { } else {
log.Info(me.urlbase, "is maybe not working GOT:", line) log.Info(me.urlbase, "is maybe not working GOT:", line)
log.Info(me.urlbase, "fail count", me.failcount, "from hostname", me.forge.Machine.Hostname) log.Info(me.urlbase, "fail count", me.failcount, "from hostname", me.machine.Hostname)
} }
} }
return nil return nil

View File

@ -7,17 +7,18 @@ import (
"time" "time"
"go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/zoopb"
) )
var me *stuff var me *stuff
// this app's variables // this app's variables
type stuff struct { type stuff 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
dog *time.Ticker // the watchdog timer dog *time.Ticker // the watchdog timer
// machine zoopb.Machine // populated from protobuf based zoopb machine *zoopb.Machine // populated from protobuf based zoopb
forge *forgepb.Forge // handle to forge forge *forgepb.Forge // handle to forge
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

View File

@ -34,7 +34,7 @@ func NewWatchdog() {
return return
case _ = <-me.dog.C: case _ = <-me.dog.C:
// log.Info("Watchdog() ticked", me.zookeeper, "Current time: ", t) // log.Info("Watchdog() ticked", me.zookeeper, "Current time: ", t)
s := me.forge.Machine.UpdatePackages() s := me.machine.UpdatePackages()
// pingStatus() // pingStatus()
me.failcount += 1 me.failcount += 1
sendMachine(s) sendMachine(s)