Skip to content

Commit

Permalink
implement finalizers for graceful shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMHD committed Feb 20, 2024
1 parent be3c63e commit 619fdc8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ func main() {

select {
case err := <-errChan:
finalizers()
reportFatalErrorAndExit(err, "cerberus error")
case <-ctx.Done():
finalizers()
os.Exit(0)
}
}
Expand Down Expand Up @@ -269,3 +271,12 @@ func reportFatalErrorAndExit(err error, msg string) {
setupLog.Error(err, msg)
os.Exit(1)
}

func finalizers() {
err := tracing.Shutdown(context.Background())
if err != nil {
setupLog.Error(err, "failed to shutdown tracing properly")
} else {
setupLog.Info("tracer shutdown properly")
}
}

0 comments on commit 619fdc8

Please sign in to comment.