diff options
| author | Jeff Carr <[email protected]> | 2025-02-22 07:17:28 -0600 | 
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-02-22 07:17:28 -0600 | 
| commit | 58ad49600aa3edc0d020a4ae4cd6d80a6347a730 (patch) | |
| tree | 5eb32646b56c8beb642369821507b8befa25231c | |
| parent | 2152a6477fc93581948ef42acea72bb97b7aae49 (diff) | |
| -rw-r--r-- | main.go | 3 | ||||
| -rw-r--r-- | send.go | 10 | ||||
| -rw-r--r-- | structs.go | 11 | ||||
| -rw-r--r-- | watchdog.go | 2 | 
4 files changed, 14 insertions, 12 deletions
@@ -10,6 +10,7 @@ import (  	"go.wit.com/dev/alexflint/arg"  	"go.wit.com/lib/protobuf/forgepb" +	"go.wit.com/lib/protobuf/zoopb"  	"go.wit.com/log"  ) @@ -46,7 +47,7 @@ func main() {  	// me.machine.ConfigLoad()  	me.forge = forgepb.InitPB() -	me.forge.InitMachine() +	me.machine = zoopb.InitMachine()  	go NewWatchdog() @@ -13,9 +13,9 @@ import (  func pingStatus() error {  	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 {  			log.Info("proto.Marshal() failed:", err)  			return err @@ -23,7 +23,7 @@ func pingStatus() error {  		log.Info("proto Marshal len =", len(msg))  	*/ -	body, err := me.forge.HttpPostMachine(url) +	body, err := me.machine.HttpPostMachine(url)  	if err != nil {  		log.Info("httpPost() failed:", err)  		return err @@ -45,7 +45,7 @@ func pingStatus() error {  func sendMachine(s string) error {  	var url string  	url = me.urlbase + "/machine" -	body, err := me.forge.HttpPostMachine(url) +	body, err := me.machine.HttpPostMachine(url)  	if err != nil {  		log.Info("httpPost() failed: url", url)  		log.Info("httpPost() failed:", err) @@ -71,7 +71,7 @@ func sendMachine(s string) error {  			os.Exit(0)  		} else {  			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 @@ -7,17 +7,18 @@ import (  	"time"  	"go.wit.com/lib/protobuf/forgepb" +	"go.wit.com/lib/protobuf/zoopb"  )  var me *stuff  // this app's variables  type stuff struct { -	urlbase   string        // the dns name for the zookeeper -	hostname  string        // my hostname -	pollDelay time.Duration // how often to report our status -	dog       *time.Ticker  // the watchdog timer -	// machine      zoopb.Machine  // populated from protobuf based zoopb +	urlbase      string         // the dns name for the zookeeper +	hostname     string         // my hostname +	pollDelay    time.Duration  // how often to report our status +	dog          *time.Ticker   // the watchdog timer +	machine      *zoopb.Machine // populated from protobuf based zoopb  	forge        *forgepb.Forge // handle to forge  	failcount    int            // how many times we've failed to contact the zookeeper  	failcountmax int            // after this, exit and let systemd restart the daemon diff --git a/watchdog.go b/watchdog.go index 40ce2ad..f42e516 100644 --- a/watchdog.go +++ b/watchdog.go @@ -34,7 +34,7 @@ func NewWatchdog() {  			return  		case _ = <-me.dog.C:  			// log.Info("Watchdog() ticked", me.zookeeper, "Current time: ", t) -			s := me.forge.Machine.UpdatePackages() +			s := me.machine.UpdatePackages()  			// pingStatus()  			me.failcount += 1  			sendMachine(s)  | 
