Skip to content

Commit

Permalink
Distinguishable exit codes
Browse files Browse the repository at this point in the history
0: normal or expected exit
1: error before server finished starting
2: double SIGINT (force quit)
3: error stopping with SIGQUIT
4: shutdown callback(s) returned error(s)
  • Loading branch information
mholt committed Aug 2, 2017
1 parent 65bc696 commit cbb8553
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions sigtrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func trapSignalsCrossPlatform() {
if PidFile != "" {
os.Remove(PidFile)
}
os.Exit(1)
os.Exit(2)
}

log.Println("[INFO] SIGINT: Shutting down")
Expand Down Expand Up @@ -62,7 +62,7 @@ func executeShutdownCallbacks(signame string) (exitCode int) {
for _, err := range errs {
log.Printf("[ERROR] %s shutdown: %v", signame, err)
}
exitCode = 1
exitCode = 4
}
})
return
Expand Down
2 changes: 1 addition & 1 deletion sigtrap_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func trapSignalsPosix() {
err := Stop()
if err != nil {
log.Printf("[ERROR] SIGQUIT stop: %v", err)
exitCode = 1
exitCode = 3
}
if PidFile != "" {
os.Remove(PidFile)
Expand Down

0 comments on commit cbb8553

Please sign in to comment.