summaryrefslogtreecommitdiff
path: root/http.go
diff options
context:
space:
mode:
Diffstat (limited to 'http.go')
-rw-r--r--http.go35
1 files changed, 18 insertions, 17 deletions
diff --git a/http.go b/http.go
index 59a30be..ebcaa70 100644
--- a/http.go
+++ b/http.go
@@ -20,18 +20,9 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
var tmp string
tmp = cleanURL(r.URL.Path)
- log.Info("Handling URL:", tmp)
- if tmp == "/" {
- fmt.Fprintln(w, "OK")
- return
- }
- if tmp == "/me" {
- fmt.Fprintln(w, "OK")
- return
- }
-
// list all the droplets
if tmp == "/droplets" {
+ log.Info("Handling URL:", tmp)
for _, d := range me.droplets {
dur := time.Since(d.lastpoll) // Calculate the elapsed time
fmt.Fprintln(w, d.Hostname, d.hname, shell.FormatDuration(dur))
@@ -56,9 +47,9 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
}
}
if good {
- fmt.Fprintln(w, "GOOD=true")
+ fmt.Fprintln(w, "Handling URL:", tmp, "GOOD=true")
} else {
- fmt.Fprintln(w, "GOOD=false")
+ fmt.Fprintln(w, "Handling URL:", tmp, "GOOD=false")
}
return
}
@@ -69,18 +60,28 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
}
if tmp == "/uptime" {
if clusterHealthy() {
+ log.Info("Handling URL:", tmp, "1 GOOD=true")
fmt.Fprintln(w, "GOOD=true")
} else {
+ log.Info("Handling URL:", tmp, "1 GOOD=false")
fmt.Fprintln(w, "GOOD=false")
}
+ for _, h := range me.hypers {
+ dur := time.Since(h.lastpoll) // Calculate the elapsed time
+ if dur > 2 * time.Minute {
+ url := "http://" + h.Hostname + ":2520/kill"
+ log.Info("KILL DAEMON ON", h.Hostname, shell.FormatDuration(dur), "curl", url)
+ }
+ // l := shell.FormatDuration(dur)
+ // log.Warn("HOST =", h.Hostname, "Last poll =", l)
+ //if d.State != "ON" {
+ // continue
+ //}
+ // dur := time.Since(d.lastpoll) // Calculate the elapsed time
+ }
return
}
- // used for uptime monitor checking (like Kuma)
- if tmp == "/uptime" {
- writeFile(w, "uptime.html")
- return
- }
log.Warn("BAD URL =", tmp)
fmt.Fprintln(w, "BAD ZOOT")
// badurl(w, r.URL.String())