fix: catch server stop error (#2125)

Co-authored-by: chenwq <chenwq@mvalley.io>
pull/2132/head
charviki 2 years ago committed by GitHub
parent a0e624c0b8
commit a3439c9713
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      app.go

@ -116,15 +116,11 @@ func (a *App) Run() error {
c := make(chan os.Signal, 1)
signal.Notify(c, a.opts.sigs...)
eg.Go(func() error {
for {
select {
case <-ctx.Done():
return ctx.Err()
return nil
case <-c:
if err := a.Stop(); err != nil {
return err
}
}
return a.Stop()
}
})
if err := eg.Wait(); err != nil && !errors.Is(err, context.Canceled) {

Loading…
Cancel
Save