[WIP] Fix minor bugs

This commit is contained in:
Vladimir Stoilov
2024-10-08 09:47:29 +03:00
parent a79be8b6a9
commit a8517cd65f
6 changed files with 21 additions and 17 deletions

View File

@@ -6,7 +6,6 @@ import (
"os"
"os/exec"
"os/signal"
"strings"
"syscall"
"time"
@@ -113,17 +112,15 @@ func runServiceRestart() error {
restartCommand, exists := os.LookupEnv("PORTMASTER_RESTART_COMMAND")
// Run the service restart
var cmd *exec.Cmd
if exists && restartCommand != "" {
log.Debugf(`instance: running custom restart command: "%s"`, restartCommand)
commandSplit := strings.Split(restartCommand, " ")
cmd := exec.Command(commandSplit[0], commandSplit[1:]...)
_ = cmd.Run()
cmd = exec.Command("sh", "-c", restartCommand)
} else {
cmd := exec.Command("systemctl", "restart", "portmaster")
if err := cmd.Start(); err != nil {
return fmt.Errorf("failed run restart command: %w", err)
}
cmd = exec.Command("systemctl", "restart", "portmaster")
}
if err := cmd.Start(); err != nil {
return fmt.Errorf("failed run restart command: %w", err)
}
return nil
}

View File

@@ -47,7 +47,7 @@ service:
changes <- svc.Status{State: svc.StopPending}
ws.instance.Shutdown()
default:
log.Errorf("unexpected control request: #%d", c)
log.Errorf("unexpected control request: %+v", c)
}
}
}