From 82b681367e3ecf335b6e4e2937406d86ba4e6166 Mon Sep 17 00:00:00 2001 From: Andy Oknen Date: Fri, 15 Aug 2025 19:45:14 +0000 Subject: [PATCH] Remove sendRestartSignal function from WebUIServer as it is no longer needed for cross-platform restart handling. Clean up code by eliminating unused imports and comments related to platform-specific signal handling. --- src/webui/server.go | 17 ----------------- src/webui/server_unix.go | 13 +++++++++++++ src/webui/server_windows.go | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 17 deletions(-) create mode 100644 src/webui/server_unix.go create mode 100644 src/webui/server_windows.go diff --git a/src/webui/server.go b/src/webui/server.go index d897a0ee..a697442f 100644 --- a/src/webui/server.go +++ b/src/webui/server.go @@ -9,10 +9,8 @@ import ( "net" "net/http" "os" - "runtime" "strings" "sync" - "syscall" "time" "github.com/yggdrasil-network/yggdrasil-go/src/admin" @@ -609,18 +607,3 @@ func (w *WebUIServer) restartServer() { w.log.Infof("Please restart Yggdrasil manually to apply configuration changes") } } - -// sendRestartSignal sends a restart signal to the process in a cross-platform way -func sendRestartSignal(proc *os.Process) error { - // Platform-specific signal handling - switch runtime.GOOS { - case "windows": - // Windows doesn't support SIGUSR1, so we'll use a different approach - // For now, we'll just log that manual restart is needed - // In the future, this could be enhanced with Windows-specific restart mechanisms - return fmt.Errorf("automatic restart not supported on Windows") - default: - // Unix-like systems support SIGUSR1 - return proc.Signal(syscall.SIGUSR1) - } -} diff --git a/src/webui/server_unix.go b/src/webui/server_unix.go new file mode 100644 index 00000000..aed6d1ec --- /dev/null +++ b/src/webui/server_unix.go @@ -0,0 +1,13 @@ +//go:build !windows + +package webui + +import ( + "os" + "syscall" +) + +// sendRestartSignal sends a restart signal to the process on Unix-like systems +func sendRestartSignal(proc *os.Process) error { + return proc.Signal(syscall.SIGUSR1) +} diff --git a/src/webui/server_windows.go b/src/webui/server_windows.go new file mode 100644 index 00000000..bc5c77b7 --- /dev/null +++ b/src/webui/server_windows.go @@ -0,0 +1,16 @@ +//go:build windows + +package webui + +import ( + "fmt" + "os" +) + +// sendRestartSignal sends a restart signal to the process on Windows +func sendRestartSignal(proc *os.Process) error { + // Windows doesn't support SIGUSR1, so we'll use a different approach + // For now, we'll just log that manual restart is needed + // In the future, this could be enhanced with Windows-specific restart mechanisms + return fmt.Errorf("automatic restart not supported on Windows") +}