Selaa lähdekoodia

Log before sending SIGINT

gabrielseibel1 1 vuosi sitten
vanhempi
commit
59add9dd04
1 muutettua tiedostoa jossa 5 lisäystä ja 2 poistoa
  1. 5 2
      controllers/server.go

+ 5 - 2
controllers/server.go

@@ -7,6 +7,7 @@ import (
 	"syscall"
 
 	"github.com/gorilla/mux"
+	"golang.org/x/exp/slog"
 
 	"github.com/gravitl/netmaker/database"
 	"github.com/gravitl/netmaker/logic"
@@ -27,9 +28,11 @@ func serverHandlers(r *mux.Router) {
 	r.HandleFunc(
 		"/api/server/health",
 		func(w http.ResponseWriter, _ *http.Request) {
-			_ = syscall.Kill(syscall.Getpid(), syscall.SIGINT)
+			msg := "received api call to restart server, sending interruption..."
+			slog.Warn(msg)
+			_, _ = w.Write([]byte(msg))
 			w.WriteHeader(http.StatusOK)
-			_, _ = w.Write([]byte("Shutting down server..."))
+			_ = syscall.Kill(syscall.Getpid(), syscall.SIGINT)
 		},
 	).Methods(http.MethodDelete)
 	r.HandleFunc("/api/server/getconfig", allowUsers(http.HandlerFunc(getConfig))).