mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-23 14:07:11 +02:00
zero/cmd: make it more evident what caused shutdown (#5209)
This commit is contained in:
parent
e2251b2d57
commit
09f1585b01
2 changed files with 12 additions and 6 deletions
|
@ -56,8 +56,10 @@ func IsManagedMode(configFile string) bool {
|
|||
}
|
||||
|
||||
func withInterrupt(ctx context.Context) context.Context {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
ctx, cancel := context.WithCancelCause(ctx)
|
||||
go func(ctx context.Context) {
|
||||
defer cancel(context.Canceled)
|
||||
|
||||
ch := make(chan os.Signal, 2)
|
||||
defer signal.Stop(ch)
|
||||
|
||||
|
@ -66,10 +68,9 @@ func withInterrupt(ctx context.Context) context.Context {
|
|||
|
||||
select {
|
||||
case sig := <-ch:
|
||||
log.Ctx(ctx).Info().Str("signal", sig.String()).Msg("quitting...")
|
||||
cancel(fmt.Errorf("received signal: %s", sig))
|
||||
case <-ctx.Done():
|
||||
}
|
||||
cancel()
|
||||
}(ctx)
|
||||
return ctx
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue