feat(system): enhance system architecture
build-and-release / release (push) Successful in 2m39s

This commit is contained in:
2026-06-25 14:44:47 +02:00
parent 54108c263f
commit d4364a6cb7
17 changed files with 783 additions and 617 deletions
+3 -8
View File
@@ -3,10 +3,8 @@ package services
import (
"context"
"encoding/json"
"os/exec"
"regexp"
"strings"
"syscall"
"nadir/internal/oscmd"
@@ -166,14 +164,11 @@ func isSelf(unit string) bool {
// Returns success once the subprocess has *started* — the actual systemd
// operation may complete after the response is sent, which is the whole point.
func runDetached(action, unit string) (*oscmd.StatusOutput, error) {
cmd := exec.Command("systemctl", action, "--", unit)
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
if err := cmd.Start(); err != nil {
out, err := oscmd.RunDetached("systemctl", action, "--", unit)
if err != nil {
return nil, huma.Error500InternalServerError("could not start detached systemctl", err)
}
// Reap in the background so the child doesn't become a zombie.
go cmd.Wait()
return oscmd.OK(), nil
return out, nil
}
// validateUnit guards against empty, flag-like, or malformed unit names.