cmd/routed: signal shutdown better

This commit is contained in:
Cadey Ratio 2018-01-20 09:30:47 -08:00
parent 0862521d93
commit cce1197484
1 changed files with 4 additions and 1 deletions

View File

@ -68,7 +68,7 @@ func main() {
signal.Notify(ch, os.Interrupt)
time.Sleep(30 * time.Second)
<-ctx.Done()
wg.Wait()
}
@ -91,6 +91,7 @@ func setupHTTP(ctx context.Context, wg *sync.WaitGroup, s *Server, scfg Config)
for {
select {
case <-ctx.Done():
ln.Log(ctx, ln.F{"kind": "http"}, ln.Action("shutdown signal recieved"))
hs.SetKeepAlivesEnabled(false)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
@ -125,6 +126,7 @@ func setupQuic(ctx context.Context, wg *sync.WaitGroup, s *Server, scfg Config)
for {
select {
case <-ctx.Done():
ln.Log(ctx, ln.F{"kind": "quic"}, ln.Action("shutdown signal recieved"))
qs.SetKeepAlivesEnabled(false)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
@ -155,6 +157,7 @@ func setupTLS(ctx context.Context, wg *sync.WaitGroup, s *Server, scfg Config) {
for {
select {
case <-ctx.Done():
ln.Log(ctx, ln.F{"kind": "https"}, ln.Action("shutdown signal recieved"))
hs.SetKeepAlivesEnabled(false)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)