add more debug stuffs.
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-07-20 20:15:55 +02:00
parent f4d324da9b
commit b249a495a4
8 changed files with 41 additions and 20 deletions
+19
View File
@@ -2,7 +2,9 @@ package main
import (
"context"
"encoding/json"
"log"
"net/http"
"os"
"os/signal"
"strings"
@@ -31,6 +33,23 @@ func main() {
os.Exit(1)
}
if conf.Debug.Enabled {
mux := http.NewServeMux()
mux.HandleFunc("/state", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
_ = json.NewEncoder(w).Encode(bot.ClientState())
})
go func() {
err := http.ListenAndServe(conf.Debug.Listen, mux)
if err != nil {
log.Println("Failed to setup debug listener", err)
}
}()
}
// Listen for a quit signal.
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, os.Interrupt)