Maint: better log when cathing an OS signal
This commit is contained in:
@@ -59,9 +59,9 @@ func main() {
|
|||||||
Created: created,
|
Created: created,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
background := context.Background()
|
||||||
ctx, stop := signal.NotifyContext(ctx, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
|
signalCtx, stop := signal.NotifyContext(background, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(background)
|
||||||
|
|
||||||
logger := logging.NewParent(logging.Settings{
|
logger := logging.NewParent(logging.Settings{
|
||||||
Level: logging.LevelInfo,
|
Level: logging.LevelInfo,
|
||||||
@@ -79,9 +79,11 @@ func main() {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-signalCtx.Done():
|
||||||
stop()
|
stop()
|
||||||
|
fmt.Println("")
|
||||||
logger.Warn("Caught OS signal, shutting down")
|
logger.Warn("Caught OS signal, shutting down")
|
||||||
|
cancel()
|
||||||
case err := <-errorCh:
|
case err := <-errorCh:
|
||||||
stop()
|
stop()
|
||||||
close(errorCh)
|
close(errorCh)
|
||||||
|
|||||||
Reference in New Issue
Block a user