From 08cbb7a330dc02c778653cd15548201633bb21ab Mon Sep 17 00:00:00 2001 From: Pulse Monitor Date: Wed, 10 Sep 2025 12:33:20 +0000 Subject: [PATCH] refactor: improve service name detection compatibility (addresses #430) - Use centralized detectServiceName() function instead of duplicate logic - Automatically detect whether system uses 'pulse' or 'pulse-backend' service - Improves compatibility between official and community installer scripts - Reduces confusion when users mix installation methods --- internal/api/router.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/api/router.go b/internal/api/router.go index c6ddb51d9..15003ff30 100644 --- a/internal/api/router.go +++ b/internal/api/router.go @@ -341,9 +341,11 @@ func (r *Router) setupRoutes() { // Then restart the service - this will kill us and restart with new env time.Sleep(500 * time.Millisecond) - cmd = exec.Command("sudo", "-n", "systemctl", "restart", "pulse-backend") + // Try to restart with the detected service name + serviceName := detectServiceName() + cmd = exec.Command("sudo", "-n", "systemctl", "restart", serviceName) if err := cmd.Run(); err != nil { - log.Error().Err(err).Msg("Failed to restart service, falling back to exit") + log.Error().Err(err).Str("service", serviceName).Msg("Failed to restart service, falling back to exit") // Fallback to exit if restart fails os.Exit(0) } @@ -1214,10 +1216,7 @@ PULSE_AUTH_PASS='%s' LogAuditEvent("password_change", r.config.AuthUser, GetClientIP(req), req.URL.Path, true, "Password changed") // Detect service name for restart instructions - serviceName := "pulse" - if _, err := os.Stat("/etc/systemd/system/pulse-backend.service"); err == nil { - serviceName = "pulse-backend" - } + serviceName := detectServiceName() // Return success with manual restart instructions w.Header().Set("Content-Type", "application/json")