Add crash_on_safe_exit option to service files
This commit is contained in:
parent
dc37ab7f7c
commit
a7a8322f13
@ -36,6 +36,7 @@ type EnitService struct {
|
||||
Type string `yaml:"type"`
|
||||
StartCmd string `yaml:"start_cmd"`
|
||||
ExitMethod string `yaml:"exit_method"`
|
||||
CrashOnSafeExit bool `yaml:"crash_on_safe_exit"`
|
||||
StopCmd string `yaml:"stop_cmd,omitempty"`
|
||||
Restart string `yaml:"restart,omitempty"`
|
||||
ServiceRunPath string
|
||||
@ -147,6 +148,7 @@ func Init() {
|
||||
ExitMethod: "",
|
||||
StopCmd: "",
|
||||
Restart: "",
|
||||
CrashOnSafeExit: true,
|
||||
ServiceRunPath: "",
|
||||
restartCount: 0,
|
||||
stopChannel: make(chan bool),
|
||||
@ -367,8 +369,13 @@ func (service *EnitService) StartService() error {
|
||||
_ = service.setCurrentState(EnitServiceCompleted)
|
||||
return
|
||||
}
|
||||
if !service.CrashOnSafeExit {
|
||||
logger.Printf("Service (%s) has exited\n", service.Name)
|
||||
_ = service.setCurrentState(EnitServiceStopped)
|
||||
} else {
|
||||
logger.Printf("Service (%s) has crashed!\n", service.Name)
|
||||
_ = service.setCurrentState(EnitServiceCrashed)
|
||||
}
|
||||
|
||||
if service.Restart == "always" {
|
||||
_ = service.StartService()
|
||||
|
Loading…
x
Reference in New Issue
Block a user