fn: graceful shutdown adjustments (#498)

Graceful shutdown should wait for Shutdown call instead of
ListenAndServe. This is because ListenAndServe returns
immediately upon Shutdown call.
This commit is contained in:
Tolga Ceylan
2017-11-13 17:58:15 -08:00
committed by Reed Allman
parent ef43e2c772
commit af8eed098d
2 changed files with 18 additions and 10 deletions

View File

@@ -41,7 +41,7 @@ func init() {
}
}
func contextWithSignal(ctx context.Context, signals ...os.Signal) context.Context {
func contextWithSignal(ctx context.Context, signals ...os.Signal) (context.Context, context.CancelFunc) {
newCTX, halt := context.WithCancel(ctx)
c := make(chan os.Signal, 1)
signal.Notify(c, signals...)
@@ -59,5 +59,5 @@ func contextWithSignal(ctx context.Context, signals ...os.Signal) context.Contex
}
}
}()
return newCTX
return newCTX, halt
}