Skip to content

Commit

Permalink
Add more tracing logs to graceful quit safeguards
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwasila committed Feb 2, 2020
1 parent 691879b commit 22b2239
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gracefullquit.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,20 @@ type safeBlock struct{}
// SafeBlock marks start of code block that should be guarded
func SafeBlock() safeBlock {
safeGroup.Add(1)
logrus.Trace("Entering safeguarded block")
return safeBlock{}
}

// StopBlocking marks end of code block that should be guarded
func StopBlocking(safeBlock) {
logrus.Trace("Leaving safeguarded block")
safeGroup.Done()
}

// SafeQuit won't return if there is any guarded block of code
// that is still executed.
func SafeQuit() {
logrus.Trace("Waiting for all safeguarded blocks to be leaved")
safeGroup.Wait()
logrus.Trace("It's now safe to turn off your application")
}

0 comments on commit 22b2239

Please sign in to comment.