parent
4883c26547
commit
a4a2d7a01f
35
http.go
35
http.go
|
@ -19,15 +19,16 @@ func cleanURL(url string) string {
|
||||||
func okHandler(w http.ResponseWriter, r *http.Request) {
|
func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
var route string
|
var route string
|
||||||
route = cleanURL(r.URL.Path)
|
route = cleanURL(r.URL.Path)
|
||||||
|
log.HttpMode(w)
|
||||||
|
defer log.HttpMode(nil)
|
||||||
|
|
||||||
if route == "/uptime" {
|
if route == "/uptime" {
|
||||||
ok, s := uptimeCheck()
|
ok, s := uptimeCheck()
|
||||||
|
log.Info(s)
|
||||||
if ok {
|
if ok {
|
||||||
log.Info("Handling URL:", route, "cluster is ok", s)
|
log.Info("Handling URL:", route, "cluster is ok")
|
||||||
fmt.Fprintln(w, s)
|
|
||||||
} else {
|
} else {
|
||||||
log.Info("Handling URL:", route, "cluster is not right yet", s)
|
log.Info("Handling URL:", route, "cluster is not right yet")
|
||||||
fmt.Fprintln(w, s)
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -36,50 +37,44 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
hostname := r.URL.Query().Get("hostname")
|
hostname := r.URL.Query().Get("hostname")
|
||||||
if hostname == "" {
|
if hostname == "" {
|
||||||
log.Warn("start failed. hostname is blank", cleanURL(r.URL.Path))
|
log.Warn("start failed. hostname is blank", cleanURL(r.URL.Path))
|
||||||
fmt.Fprintln(w, "start failed. hostname is blank", cleanURL(r.URL.Path))
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Warn("hostname is", hostname)
|
log.Warn("hostname is", hostname)
|
||||||
fmt.Fprintln(w, "hostname is", hostname)
|
|
||||||
|
|
||||||
// log.Warn("Handling URL:", tmp, "start droplet", start)
|
// log.Warn("Handling URL:", tmp, "start droplet", start)
|
||||||
result, err := Start(hostname)
|
result, err := Start(hostname)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
fmt.Fprintln(w, result)
|
log.Info(result)
|
||||||
fmt.Fprintln(w, hostname, "started output ok")
|
log.Info(hostname, "started output ok")
|
||||||
fmt.Fprintln(w, hostname, "need to parse the output here")
|
log.Info(hostname, "need to parse the output here")
|
||||||
fmt.Fprintln(w, hostname, "todo: switch to protobuf here")
|
log.Info(hostname, "todo: switch to protobuf here")
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintln(w, result)
|
log.Info(result)
|
||||||
fmt.Fprintln(w, err)
|
log.Info(err)
|
||||||
fmt.Fprintln(w, hostname, "start failed")
|
log.Info(hostname, "start failed")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if route == "/import" {
|
if route == "/import" {
|
||||||
log.Info("virtigo import starts here")
|
log.Info("virtigo import starts here")
|
||||||
fmt.Fprintln(w, "virtigo import starts here")
|
|
||||||
result, err := importDomain(w, r)
|
result, err := importDomain(w, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info("virtigo import failed")
|
log.Info("virtigo import failed")
|
||||||
log.Info(result)
|
log.Info(result)
|
||||||
fmt.Fprintln(w, "virtigo import failed")
|
|
||||||
fmt.Fprintln(w, result)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info("virtigo import worked")
|
log.Info("virtigo import worked")
|
||||||
fmt.Fprintln(w, "virtigo import worked")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// toggle poll logging
|
// toggle poll logging
|
||||||
if route == "/poll" {
|
if route == "/poll" {
|
||||||
if POLL.Get() {
|
if POLL.Get() {
|
||||||
fmt.Fprintln(w, "POLL is true")
|
log.Info("POLL is true")
|
||||||
POLL.SetBool(false)
|
POLL.SetBool(false)
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintln(w, "POLL is false")
|
log.Info("POLL is false")
|
||||||
POLL.SetBool(true)
|
POLL.SetBool(true)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -117,7 +112,6 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
if route == "/quit" {
|
if route == "/quit" {
|
||||||
log.Warn("writing out config file and exiting virtigo")
|
log.Warn("writing out config file and exiting virtigo")
|
||||||
fmt.Fprintln(w, "writing out config file and exiting virtigo")
|
|
||||||
if err := me.cluster.ConfigSave(); err != nil {
|
if err := me.cluster.ConfigSave(); err != nil {
|
||||||
log.Info("configsave error", err)
|
log.Info("configsave error", err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -140,7 +134,6 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Warn("BAD URL =", route)
|
log.Warn("BAD URL =", route)
|
||||||
fmt.Fprintln(w, "BAD URL tmp =", route)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// write a file out to the http socket
|
// write a file out to the http socket
|
||||||
|
|
Loading…
Reference in New Issue