summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--event.go6
-rw-r--r--http.go14
-rw-r--r--poll.go11
-rw-r--r--structs.go1
5 files changed, 26 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index a4b8953..3443eda 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/event.go b/event.go
index c6e4bb5..ee4bef0 100644
--- a/event.go
+++ b/event.go
@@ -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)
+}
diff --git a/http.go b/http.go
index d94a6a1..16dc79b 100644
--- a/http.go
+++ b/http.go
@@ -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())
diff --git a/poll.go b/poll.go
index f7f2414..981bf86 100644
--- a/poll.go
+++ b/poll.go
@@ -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
diff --git a/structs.go b/structs.go
index 94d7ce5..b97d35f 100644
--- a/structs.go
+++ b/structs.go
@@ -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