start worked from protobuf

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-26 20:09:33 -05:00
parent 970e6c24dc
commit 170f548a61
3 changed files with 13 additions and 6 deletions

View File

@ -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/apps/go-clone
go-clone --recursive --go-src --no-work go.wit.com/lib/daemons/virtigod 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: start-pihole.wit.com-http:
curl --silent http://localhost:8080/start?start=pihole.wit.com 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

10
http.go
View File

@ -68,6 +68,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
} }
if tmp == "/start" { if tmp == "/start" {
log.Info("/start jcarr actually doing START")
fmt.Fprintln(w, "/start jcarr actually doing START") fmt.Fprintln(w, "/start jcarr actually doing START")
start := r.URL.Query().Get("start") start := r.URL.Query().Get("start")
xml := "/tmp/" + start + ".xml" xml := "/tmp/" + start + ".xml"
@ -79,6 +80,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
} }
// fmt.Fprintln(w, "HTTP:", r.Body) // fmt.Fprintln(w, "HTTP:", r.Body)
var d *pb.Droplet var d *pb.Droplet
d = new(pb.Droplet)
// msg, err := ioutil.ReadAll(r.Body) // Read the body as []byte // msg, err := ioutil.ReadAll(r.Body) // Read the body as []byte
fmt.Fprintln(w, "/start ReadAll() START") fmt.Fprintln(w, "/start ReadAll() START")
fmt.Fprintln(w, "msg =", string(msg)) fmt.Fprintln(w, "msg =", string(msg))
@ -89,7 +91,13 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
fmt.Fprintln(w, "START len(msg) =", len(msg)) 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 { if err != nil {
fmt.Fprintln(w, "START FAILED") fmt.Fprintln(w, "START FAILED")
fmt.Fprintln(w, "error =", err) fmt.Fprintln(w, "error =", err)

View File

@ -14,7 +14,7 @@ import (
func newStart(start string, d *pb.Droplet) error { func newStart(start string, d *pb.Droplet) error {
// d := me.cluster.FindDroplet(start) // d := me.cluster.FindDroplet(start)
if d == nil { if d == nil {
log.Info("droplet is unknown:", start) log.Info("log.Info: droplet is unknown:", start)
return errors.New("droplet is unknown: " + start) return errors.New("droplet is unknown: " + start)
} }
log.Info("start droplet here:", d.Hostname) log.Info("start droplet here:", d.Hostname)