diff --git a/http.go b/http.go index 3ce0c06..b0a9f8c 100644 --- a/http.go +++ b/http.go @@ -60,20 +60,15 @@ func okHandler(w http.ResponseWriter, r *http.Request) { } if route == "/status" { - if hostname == "" { - // ignore junk - log.Info("hostname was blank") - return - } var packs *zoopb.Packages packs = new(zoopb.Packages) if err := packs.Unmarshal(msg); err != nil { - log.Info("proto.Unmarshal() failed on wire message len", len(msg), "from", hostname) + log.Info("/status proto.Unmarshal() failed on wire message len", len(msg), "from", hostname) return } - log.Info("Unmarshal worked with msg len", len(msg), "from", hostname) - log.Info(hostname, "has", packs.Len(), "packages installed") + log.Info("/status Unmarshal worked with msg len", len(msg), "from", hostname) + log.Info("/status hostname", hostname, "has", packs.Len(), "packages installed") fmt.Fprintln(w, "upgrade") return } @@ -100,14 +95,11 @@ func okHandler(w http.ResponseWriter, r *http.Request) { if route == "/save" { log.HttpMode(w) defer log.HttpMode(nil) - data, err := me.machines.Marshal() - if err != nil { - log.Info("proto.Marshal() failed len", len(msg), err) - return + if err := me.machines.ConfigSave(); err == nil { + log.Log(NOW, "ConfigSave() ok") + } else { + log.Log(NOW, "ConfigSave() failed", err) } - log.Info("proto.Marshal() worked len", len(msg)) - // me.machines.ConfigSave() - zoopb.ConfigSaveRaw(data) return } diff --git a/main.go b/main.go index b47b6eb..1f4b2a6 100644 --- a/main.go +++ b/main.go @@ -48,6 +48,10 @@ func main() { me.hostname, _ = os.Hostname() me.pollDelay = 10 * time.Second me.machines = new(zoopb.Machines) + if err := me.machines.ConfigLoad(); err != nil { + log.Warn("load config failed", err) + os.Exit(-1) + } me.targets = make(map[string]string) // keep track of what versions the machines should be running me.upgrade = make(map[string]bool) // used to trigger upgrade attempts