summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go3
-rw-r--r--send.go10
-rw-r--r--structs.go11
-rw-r--r--watchdog.go2
4 files changed, 14 insertions, 12 deletions
diff --git a/main.go b/main.go
index 7258a47..1819d77 100644
--- a/main.go
+++ b/main.go
@@ -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()
diff --git a/send.go b/send.go
index 43efc6e..2636d5c 100644
--- a/send.go
+++ b/send.go
@@ -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
diff --git a/structs.go b/structs.go
index 0f2330f..bb07847 100644
--- a/structs.go
+++ b/structs.go
@@ -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)