mirror of
https://github.com/go-kratos/kratos.git
synced 2025-01-14 02:33:03 +02:00
fix: catch server stop error (#2125)
Co-authored-by: chenwq <chenwq@mvalley.io>
This commit is contained in:
parent
a0e624c0b8
commit
a3439c9713
14
app.go
14
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()
|
||||
case <-c:
|
||||
if err := a.Stop(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
case <-c:
|
||||
return a.Stop()
|
||||
}
|
||||
})
|
||||
if err := eg.Wait(); err != nil && !errors.Is(err, context.Canceled) {
|
||||
|
Loading…
Reference in New Issue
Block a user