mirror of
https://github.com/safing/portbase
synced 2025-04-14 06:29:09 +00:00
Improve exit code handling in run package
This commit is contained in:
parent
ddf230b33e
commit
9e8d1fdd4d
1 changed files with 11 additions and 1 deletions
12
run/main.go
12
run/main.go
|
@ -33,6 +33,7 @@ func Run() int {
|
|||
// Start
|
||||
err := modules.Start()
|
||||
if err != nil {
|
||||
// Immediately return for a clean exit.
|
||||
if errors.Is(err, modules.ErrCleanExit) {
|
||||
return 0
|
||||
}
|
||||
|
@ -41,8 +42,17 @@ func Run() int {
|
|||
printStackTo(os.Stdout, "PRINTING STACK ON EXIT (STARTUP ERROR)")
|
||||
}
|
||||
|
||||
// Trigger shutdown and wait for it to complete.
|
||||
_ = modules.Shutdown()
|
||||
return modules.GetExitStatusCode()
|
||||
exitCode := modules.GetExitStatusCode()
|
||||
|
||||
// Return the exit code, if it was set.
|
||||
if exitCode > 0 {
|
||||
return exitCode
|
||||
}
|
||||
|
||||
// Otherwise, return a default 1.
|
||||
return 1
|
||||
}
|
||||
|
||||
// Shutdown
|
||||
|
|
Loading…
Add table
Reference in a new issue