handle shutdown signal
This commit is contained in:
parent
8f346786f5
commit
5077b2e4bf
1 changed files with 13 additions and 1 deletions
|
@ -108,6 +108,8 @@ func main() {
|
||||||
s.MaxRecipients = 10
|
s.MaxRecipients = 10
|
||||||
s.AuthDisabled = true
|
s.AuthDisabled = true
|
||||||
|
|
||||||
|
defer s.Close() // nolint:errcheck
|
||||||
|
|
||||||
log.Info("starting health service")
|
log.Info("starting health service")
|
||||||
|
|
||||||
go runHealthService(cm)
|
go runHealthService(cm)
|
||||||
|
@ -126,7 +128,17 @@ func main() {
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Fatal("server exited", zap.Error(s.ListenAndServe()))
|
go func() {
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
if err := s.ListenAndServe(); err != nil {
|
||||||
|
log.Error("listener failed", zap.Error(err))
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
<-ctx.Done()
|
||||||
|
|
||||||
|
log.Info("exiting")
|
||||||
}
|
}
|
||||||
|
|
||||||
func runHealthService(cm *localtls.CertManager) {
|
func runHealthService(cm *localtls.CertManager) {
|
||||||
|
|
Loading…
Reference in a new issue