diff options
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | event.go | 6 | ||||
| -rw-r--r-- | http.go | 14 | ||||
| -rw-r--r-- | poll.go | 11 | ||||
| -rw-r--r-- | structs.go | 1 |
5 files changed, 26 insertions, 9 deletions
@@ -10,7 +10,8 @@ all: ./virtigo --hosts farm01 farm02 farm03 start: - ./virtigo --start jcarr + curl --silent http://localhost:8080/start?start=jcarr + @# ./virtigo --start jcarr curl-uptime: curl --silent http://localhost:8080/uptime @@ -22,3 +22,9 @@ func (h *HyperT) RestartDaemon() { log.Info("KILLED DAEMON", h.Hostname, shell.FormatDuration(dur), "curl", url) me.killcount += 1 } + +func (h *HyperT) Start(d *DropletT) { + url := "http://" + h.Hostname + ":2520/start?" + d.Hostname + s := shell.Wget(url) + log.Info("EVENT start droplet", url, s) +} @@ -32,7 +32,6 @@ func okHandler(w http.ResponseWriter, r *http.Request) { // is the cluster running what it should? if tmp == "/droplets" { - var good = true for _, d := range me.droplets { if d.State != "ON" { continue @@ -40,17 +39,11 @@ func okHandler(w http.ResponseWriter, r *http.Request) { dur := time.Since(d.lastpoll) // Calculate the elapsed time if d.CurrentState != "ON" { fmt.Fprintln(w, "BAD STATE ", d.Hostname, "State =", d.State, "CurrentState =", d.CurrentState, shell.FormatDuration(dur)) - good = false } else { dur := time.Since(d.lastpoll) // Calculate the elapsed time fmt.Fprintln(w, "GOOD STATE ON", d.Hostname, d.hname, shell.FormatDuration(dur)) } } - if good { - fmt.Fprintln(w, "Handling URL:", tmp, "GOOD=true") - } else { - fmt.Fprintln(w, "Handling URL:", tmp, "GOOD=false") - } return } @@ -90,6 +83,13 @@ func okHandler(w http.ResponseWriter, r *http.Request) { return } + if tmp == "/start" { + start := r.URL.Query().Get("start") + log.Info("should start droplet here", start) + fmt.Fprintln(w, "should start droplet here", start) + return + } + log.Warn("BAD URL =", tmp) fmt.Fprintln(w, "BAD ZOOT") // badurl(w, r.URL.String()) @@ -136,8 +136,17 @@ func clusterHealthy() (bool, string) { } summary = strings.TrimSpace(summary) summary += ")" - summary += "(killcount=" + fmt.Sprintf("%d", me.killcount) + ")" + if me.killcount > 0 { + summary += "(killcount=" + fmt.Sprintf("%d", me.killcount) + ")" + } + last := time.Since(me.stable) + if last > 133*time.Second { + // the cluster has not been stable for 10 seconds + s := shell.FormatDuration(last) + summary += "(unstable " + s + ")" + } if good { + me.stable = time.Now() return good, "GOOD=true " + summary } return good, "GOOD=false " + summary @@ -20,6 +20,7 @@ type virtigoT struct { hypers []*HyperT droplets []*DropletT killcount int + stable time.Time // the latest time the cluster has been okay } // the stuff that is needed for a hypervisor |
