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()
if a.opts.registrar != nil {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(a.opts.ctx, a.opts.registrarTimeout)
defer cancel()
if err := a.opts.registrar.Register(ctx, instance); err != nil {
rctx, rcancel := context.WithTimeout(a.opts.ctx, a.opts.registrarTimeout)
defer rcancel()
if err := a.opts.registrar.Register(rctx, instance); err != nil {
return err
}
a.instance = instance

Loading…
Cancel
Save