runs and reports versions
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
4e0dc17202
commit
5d9eb5add6
22
http.go
22
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
|
||||
}
|
||||
|
||||
|
|
4
main.go
4
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue