Skip to content

Commit

Permalink
feat(use-systemd): Work in progress about the status for useSystemd s…
Browse files Browse the repository at this point in the history
…etups
  • Loading branch information
etu committed Feb 14, 2025
1 parent 23dfc55 commit da7bf54
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,26 @@ func (runner *Runner) Stop(name string, serve *Serve) error {
return nil
}

// Shorthand to know if we should use systemd or not
useSystemd := runner.config.Settings.UseSystemd

if useSystemd {
unitName := fmt.Sprintf("goprocmgr-server-%s", name)
cmd := exec.Command("systemctl", "--user", "stop", unitName)

if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to stop systemd service: %s", err)
}

// Delete old status for process
delete(runner.ActiveProcesses, name)

// Notify state change on stop
serve.stateChange <- true

return nil
}

// Add a go routine to check if the process is killed or not after
// we've told it to SIGTERM. If it's still running, send a SIGKILL
// instead to clean up.
Expand Down

0 comments on commit da7bf54

Please sign in to comment.