Skip to content

Commit

Permalink
add sentry capture for non-graceful shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwiidb committed Aug 10, 2023
1 parent f7afc52 commit b7bdae7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"fmt"
"os"
"os/signal"
"strings"
Expand Down Expand Up @@ -94,9 +95,12 @@ func main() {
}()
<-ctx.Done()
// start goroutine that will exit program after 10 seconds
// in case graceful shutdown fails
go func() {
time.Sleep(10 * time.Second)
logrus.Fatal("Exiting because of timeout. Goodbye")
nonGracefulShutdownErr := fmt.Errorf("non-graceful shutdown because of timeout")
sentry.CaptureException(nonGracefulShutdownErr)
logrus.Fatal(nonGracefulShutdownErr)

}()
//wait for goroutines to finish
Expand Down

0 comments on commit b7bdae7

Please sign in to comment.