summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--daemon.go14
-rw-r--r--send.go54
2 files changed, 41 insertions, 27 deletions
diff --git a/daemon.go b/daemon.go
index 17c486e..beb1e30 100644
--- a/daemon.go
+++ b/daemon.go
@@ -9,6 +9,7 @@ import (
"time"
"go.wit.com/lib/debian"
+ "go.wit.com/log"
)
// timeFunction takes a function as an argument and returns the execution time.
@@ -29,9 +30,16 @@ func zood() {
fmt.Println("Done!")
return
case _ = <-me.dog.C:
- s := debian.UpdatePackages(me.machine)
- me.failcount += 1
- sendMachine(s)
+ err := debian.UpdatePackages(me.machine)
+ if err != nil {
+ log.Info("UpdatePackages err", err)
+ me.failcount += 1
+ }
+ err = sendMachine(me.machine)
+ if err != nil {
+ log.Info("sendMachine err", err)
+ me.failcount += 1
+ }
if me.failcount > 20 {
os.Exit(0)
diff --git a/send.go b/send.go
index 727cbc9..78622a9 100644
--- a/send.go
+++ b/send.go
@@ -4,45 +4,50 @@
package main
import (
- "os"
- "strings"
-
- "go.wit.com/lib/gui/shell"
+ "go.wit.com/lib/protobuf/zoopb"
"go.wit.com/log"
)
func pingStatus() error {
- var url string
- url = me.urlbase + "/status?hostname=" + me.machine.Hostname
+ log.Info("fixme: does nothing")
/*
- msg, err := me.machine.Packages.Marshal()
+ var url string
+ url = me.urlbase + "/status?hostname=" + me.machine.Hostname
+
+ body, err := me.machine.HttpPostMachine(url)
if err != nil {
- log.Info("proto.Marshal() failed:", err)
+ log.Info("httpPost() failed:", err)
return err
}
- log.Info("proto Marshal len =", len(msg))
+
+ test := strings.TrimSpace(string(body))
+ // log.Info("virtigo returned body:", test)
+ for _, line := range strings.Split(test, "\n") {
+ switch line {
+ case "upgrade":
+ log.Info("should upgrade now")
+ default:
+ log.Info("GOT:", line)
+ }
+ }
*/
+ return nil
+}
- body, err := me.machine.HttpPostMachine(url)
+func sendMachine(pb *zoopb.Machine) error {
+ newpb, wsPB, err := pb.HttpPost(me.urlbase, "machine")
if err != nil {
- log.Info("httpPost() failed:", err)
+ log.Info("got error:", err)
return err
}
-
- test := strings.TrimSpace(string(body))
- // log.Info("virtigo returned body:", test)
- for _, line := range strings.Split(test, "\n") {
- switch line {
- case "upgrade":
- log.Info("should upgrade now")
- default:
- log.Info("GOT:", line)
- }
- }
- return nil
+ wsPB.DumpClient()
+ log.Infof("mem=%d cpus=%d\n", newpb.Memory, newpb.Cpus)
+ log.Info("got error:", err)
+ return err
}
-func sendMachine(s string) error {
+/*
+func sendMachineOld(s string) error {
var url string
url = me.urlbase + "/machine"
body, err := me.machine.HttpPostMachine(url)
@@ -94,3 +99,4 @@ func sendMachine(s string) error {
}
return nil
}
+*/