Remove redundant 'exit_method' field

This commit is contained in:
2025-12-03 19:03:37 +02:00
parent e1a51649ae
commit 26a6952091
+2 -11
View File
@@ -44,7 +44,6 @@ type EnitService struct {
Description string `yaml:"description,omitempty"` Description string `yaml:"description,omitempty"`
Type string `yaml:"type"` Type string `yaml:"type"`
StartCmd string `yaml:"start_cmd"` StartCmd string `yaml:"start_cmd"`
ExitMethod string `yaml:"exit_method"`
CrashOnSafeExit bool `yaml:"crash_on_safe_exit"` CrashOnSafeExit bool `yaml:"crash_on_safe_exit"`
StopCmd string `yaml:"stop_cmd,omitempty"` StopCmd string `yaml:"stop_cmd,omitempty"`
User string `yaml:"user,omitempty"` User string `yaml:"user,omitempty"`
@@ -157,7 +156,6 @@ func LoadService(filepath string) {
Description: "", Description: "",
Type: "", Type: "",
StartCmd: "", StartCmd: "",
ExitMethod: "",
StopCmd: "", StopCmd: "",
User: "", User: "",
Restart: "", Restart: "",
@@ -194,13 +192,6 @@ func LoadService(filepath string) {
return return
} }
switch newService.ExitMethod {
case "stop_command", "kill":
default:
logger.Printf("Error: unknown exit method (%s)\n", newService.ExitMethod)
return
}
switch newService.Restart { switch newService.Restart {
case "true", "always": case "true", "always":
default: default:
@@ -352,7 +343,7 @@ func (service *EnitService) StartService() (err error) {
if service.Type == "simple" && err == nil { if service.Type == "simple" && err == nil {
service.restartCount = 0 service.restartCount = 0
if service.ExitMethod != "stop_command" { if strings.TrimSpace(service.StopCmd) == "" {
service.state = EnitServiceCompleted service.state = EnitServiceCompleted
// Reload service if needed // Reload service if needed
@@ -428,7 +419,7 @@ func (service *EnitService) StopService() error {
} }
}() }()
if service.ExitMethod == "kill" { if strings.TrimSpace(service.StopCmd) == "" {
if err := service.GetProcess().Signal(syscall.Signal(0)); err != nil { if err := service.GetProcess().Signal(syscall.Signal(0)); err != nil {
newServiceStatus = EnitServiceStopped newServiceStatus = EnitServiceStopped
logger.Printf("Service (%s) has stopped (Process already dead)", service.Name) logger.Printf("Service (%s) has stopped (Process already dead)", service.Name)