Skip to content

Commit

Permalink
main method refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail <avramenkomihail15@gmail.com>
  • Loading branch information
Mixaster995 committed Apr 22, 2021
1 parent 9b6b78a commit 5725829
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
// ********************************************************************************
Expand Down Expand Up @@ -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,
)
}

0 comments on commit 5725829

Please sign in to comment.