소스 검색

Log before sending SIGINT

gabrielseibel1 1 년 전
부모
커밋
59add9dd04
1개의 변경된 파일5개의 추가작업 그리고 2개의 파일을 삭제
  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))).