diff --git a/main.go b/main.go index 82d1d20..55d8c2c 100644 --- a/main.go +++ b/main.go @@ -91,16 +91,8 @@ func main() { // ******************************************************************************** // setup context to catch signals // ******************************************************************************** - ctx, cancel := signal.NotifyContext( - context.Background(), - os.Interrupt, - // More Linux signals here - syscall.SIGHUP, - syscall.SIGTERM, - syscall.SIGQUIT, - ) + ctx, cancel := notifyContext(); defer cancel() - // ******************************************************************************** // setup logging // ******************************************************************************** @@ -289,3 +281,14 @@ func exitOnErr(ctx context.Context, cancel context.CancelFunc, errCh <-chan erro cancel() }(ctx, errCh) } + +func notifyContext() (context.Context, context.CancelFunc){ + return signal.NotifyContext( + context.Background(), + os.Interrupt, + // More Linux signals here + syscall.SIGHUP, + syscall.SIGTERM, + syscall.SIGQUIT, + ) +}