From 170f548a619b0380acb8137f24ffce0478e0b753 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 26 Oct 2024 20:09:33 -0500 Subject: [PATCH] start worked from protobuf Signed-off-by: Jeff Carr --- Makefile | 7 +++---- http.go | 10 +++++++++- start.go | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index d800fa1..96a6537 100644 --- a/Makefile +++ b/Makefile @@ -37,9 +37,8 @@ git-clone: # go-clone --recursive --go-src --no-work go.wit.com/apps/go-clone go-clone --recursive --go-src --no-work go.wit.com/lib/daemons/virtigod -start: - rm -f /tmp/pihole.wit.com.xml - ./virtigod --start pihole.wit.com - start-pihole.wit.com-http: curl --silent http://localhost:8080/start?start=pihole.wit.com + +start-bind.wit.com-http: + curl --silent http://localhost:8080/start?start=bind.wit.com diff --git a/http.go b/http.go index 746ef9b..5fb63f6 100644 --- a/http.go +++ b/http.go @@ -68,6 +68,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) { } if tmp == "/start" { + log.Info("/start jcarr actually doing START") fmt.Fprintln(w, "/start jcarr actually doing START") start := r.URL.Query().Get("start") xml := "/tmp/" + start + ".xml" @@ -79,6 +80,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) { } // fmt.Fprintln(w, "HTTP:", r.Body) var d *pb.Droplet + d = new(pb.Droplet) // msg, err := ioutil.ReadAll(r.Body) // Read the body as []byte fmt.Fprintln(w, "/start ReadAll() START") fmt.Fprintln(w, "msg =", string(msg)) @@ -89,7 +91,13 @@ func okHandler(w http.ResponseWriter, r *http.Request) { return } fmt.Fprintln(w, "START len(msg) =", len(msg)) - // err = d.UnmarshalJSON(msg) + err = d.UnmarshalJSON(msg) + if d.Hostname == "" { + fmt.Fprintln(w,"START hostname is blank") + log.Info("START hostname is blank") + return + } + if err != nil { fmt.Fprintln(w, "START FAILED") fmt.Fprintln(w, "error =", err) diff --git a/start.go b/start.go index 7c28f76..4bd3844 100644 --- a/start.go +++ b/start.go @@ -14,7 +14,7 @@ import ( func newStart(start string, d *pb.Droplet) error { // d := me.cluster.FindDroplet(start) if d == nil { - log.Info("droplet is unknown:", start) + log.Info("log.Info: droplet is unknown:", start) return errors.New("droplet is unknown: " + start) } log.Info("start droplet here:", d.Hostname)