mirror of
https://github.com/Icinga/icingadb.git
synced 2026-06-09 00:42:37 -04:00
Exit with an error code if not exiting due to a signal
Icinga DB should not exit with code 0 if it does so due to an error.
This commit is contained in:
parent
3649b367e1
commit
e0d66fe0ee
1 changed files with 12 additions and 3 deletions
|
|
@ -17,7 +17,16 @@ import (
|
|||
"syscall"
|
||||
)
|
||||
|
||||
const (
|
||||
ExitSuccess = 0
|
||||
ExitFailure = 1
|
||||
)
|
||||
|
||||
func main() {
|
||||
os.Exit(run())
|
||||
}
|
||||
|
||||
func run() int {
|
||||
cmd := command.New()
|
||||
logger := cmd.Logger
|
||||
defer logger.Sync()
|
||||
|
|
@ -103,13 +112,13 @@ func main() {
|
|||
// otherwise there is no way to get Icinga DB back into a working state.
|
||||
panic(errors.New("HA exited without an error but main context isn't cancelled"))
|
||||
}
|
||||
return
|
||||
return ExitFailure
|
||||
case <-ctx.Done():
|
||||
return
|
||||
panic(errors.New("main context closed unexpectedly"))
|
||||
case s := <-sig:
|
||||
logger.Infow("Exiting due to signal", zap.String("signal", s.String()))
|
||||
cancelCtx()
|
||||
return
|
||||
return ExitSuccess
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue