keep working towards update working
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
769c9757b7
commit
b71fec22c8
8
apt.go
8
apt.go
|
@ -28,7 +28,7 @@ func initPackages() {
|
|||
}
|
||||
}
|
||||
|
||||
log.Info(me.hostname, "has distro", me.distro, "with", me.machine.Packages.Len(), "packages installed")
|
||||
log.Info(me.hostname, "has distro", me.distro, "with", me.machine.Packages.Len(), "packages installed.")
|
||||
}
|
||||
|
||||
func addNew(name string, version string) bool {
|
||||
|
@ -38,12 +38,12 @@ func addNew(name string, version string) bool {
|
|||
return me.machine.Packages.Append(new1)
|
||||
}
|
||||
|
||||
func updatePackages() {
|
||||
func updatePackages() string {
|
||||
// Get the list of installed packages for the detected distro
|
||||
newP, err := getPackageList(me.distro)
|
||||
if err != nil {
|
||||
fmt.Println("Error:", err)
|
||||
return
|
||||
return fmt.Sprintln("getPackageList()", err)
|
||||
}
|
||||
|
||||
var newCounter, changeCounter int
|
||||
|
@ -69,5 +69,5 @@ func updatePackages() {
|
|||
if newCounter != 0 {
|
||||
footer += fmt.Sprintf(" (%d new)", newCounter)
|
||||
}
|
||||
log.Info(footer)
|
||||
return footer
|
||||
}
|
||||
|
|
21
send.go
21
send.go
|
@ -3,6 +3,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/lib/gui/shell"
|
||||
|
@ -42,7 +43,7 @@ func pingStatus() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func sendMachine() error {
|
||||
func sendMachine(s string) error {
|
||||
var url string
|
||||
url = urlbase + "/machine"
|
||||
msg, err := me.machine.Marshal()
|
||||
|
@ -50,7 +51,6 @@ func sendMachine() error {
|
|||
log.Info("proto.Marshal() failed:", err)
|
||||
return err
|
||||
}
|
||||
log.Info("proto Marshal len =", len(msg))
|
||||
body, err := httpPost(url, msg)
|
||||
if err != nil {
|
||||
log.Info("httpPost() failed:", err)
|
||||
|
@ -60,15 +60,18 @@ func sendMachine() error {
|
|||
test := strings.TrimSpace(string(body))
|
||||
// log.Info("virtigo returned body:", test)
|
||||
for _, line := range strings.Split(test, "\n") {
|
||||
switch line {
|
||||
case "upgrade":
|
||||
log.Info("zookeeper is healthy")
|
||||
case "apt update":
|
||||
log.Info("machine upgrade now")
|
||||
if line == "upgrade" {
|
||||
log.Info(s, "zookeeper is healthy", len(msg))
|
||||
} else if line == "kill" {
|
||||
os.Exit(0)
|
||||
} else if strings.HasPrefix(line, "apt update") {
|
||||
log.Info("machine upgrade now", line)
|
||||
shell.Run([]string{"apt", "update"})
|
||||
shell.Run([]string{"apt", "install", "zood"})
|
||||
default:
|
||||
log.Info("zookeeper is maybe not working GOT:", line)
|
||||
log.Sleep(1)
|
||||
os.Exit(0)
|
||||
} else {
|
||||
log.Info(urlbase, "is maybe not working GOT:", line)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
10
watchdog.go
10
watchdog.go
|
@ -3,8 +3,6 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
// timeFunction takes a function as an argument and returns the execution time.
|
||||
|
@ -30,11 +28,11 @@ func NewWatchdog() {
|
|||
case <-done:
|
||||
fmt.Println("Done!")
|
||||
return
|
||||
case t := <-me.dog.C:
|
||||
log.Info("Watchdog() ticked", me.zookeeper, "Current time: ", t)
|
||||
updatePackages()
|
||||
case _ = <-me.dog.C:
|
||||
// log.Info("Watchdog() ticked", me.zookeeper, "Current time: ", t)
|
||||
s := updatePackages()
|
||||
// pingStatus()
|
||||
sendMachine()
|
||||
sendMachine(s)
|
||||
// h.pollHypervisor()
|
||||
// h.Scan()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue