File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,13 +20,16 @@ func checkNetwork(r *http.Request) bool {
2020 return false
2121 }
2222
23- // If supervisor is down
24- if ! supervisorPing () {
25- log .Printf ("API is disabled / Supervisor is running - %s" , remote )
26- return true
23+ return true
24+ }
25+
26+ func apiPing (w http.ResponseWriter , r * http.Request ) {
27+ if r .Method != "GET" {
28+ http .Error (w , http .StatusText (http .StatusMethodNotAllowed ), http .StatusMethodNotAllowed )
29+ return
2730 }
2831
29- return false
32+ w . WriteHeader ( http . StatusOK )
3033}
3134
3235func apiLogs (w http.ResponseWriter , r * http.Request ) {
@@ -51,7 +54,7 @@ func apiLogs(w http.ResponseWriter, r *http.Request) {
5154}
5255
5356func apiRestart (w http.ResponseWriter , r * http.Request ) {
54- if ! checkNetwork (r ) {
57+ if ! checkNetwork (r ) || supervisorPing () {
5558 http .Error (w , http .StatusText (http .StatusForbidden ), http .StatusForbidden )
5659 return
5760 }
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ func main() {
4141 indexTemplate = template .Must (template .ParseFiles (wwwRoot + "/index.html" ))
4242
4343 http .HandleFunc ("/" , statusIndex )
44+ http .HandleFunc ("/ping" , apiPing )
4445 http .HandleFunc ("/logs" , apiLogs )
4546 http .HandleFunc ("/restart" , apiRestart )
4647
You can’t perform that action at this time.
0 commit comments