fix:reuse parent ctx cause unexpected stop of App (#1429)

* fix reuse parent ctx cause unexpected stop of App
pull/1431/head
longxboy 3 years ago committed by GitHub
parent fa54a1dd3a
commit 906a9ead4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      app.go

@ -99,10 +99,9 @@ func (a *App) Run() error {
} }
wg.Wait() wg.Wait()
if a.opts.registrar != nil { if a.opts.registrar != nil {
var cancel context.CancelFunc rctx, rcancel := context.WithTimeout(a.opts.ctx, a.opts.registrarTimeout)
ctx, cancel = context.WithTimeout(a.opts.ctx, a.opts.registrarTimeout) defer rcancel()
defer cancel() if err := a.opts.registrar.Register(rctx, instance); err != nil {
if err := a.opts.registrar.Register(ctx, instance); err != nil {
return err return err
} }
a.instance = instance a.instance = instance

Loading…
Cancel
Save