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.

This commit is contained in:
Andy Oknen 2025-08-15 19:45:14 +00:00
parent 8d0cbfd0ad
commit 82b681367e
3 changed files with 29 additions and 17 deletions

View file

@ -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)
}
}

13
src/webui/server_unix.go Normal file
View file

@ -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)
}

View file

@ -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")
}