feat(process): fix daemon stop order
This commit is contained in:
parent
2255ade57e
commit
686f1053b3
1 changed files with 9 additions and 7 deletions
16
daemon.go
16
daemon.go
|
|
@ -164,10 +164,10 @@ func (d *Daemon) Stop() error {
|
|||
shutdownCtx, cancel := context.WithTimeout(context.Background(), d.opts.ShutdownTimeout)
|
||||
defer cancel()
|
||||
|
||||
if d.health != nil {
|
||||
d.health.SetReady(false)
|
||||
if err := d.health.Stop(shutdownCtx); err != nil {
|
||||
errs = append(errs, coreerr.E("Daemon.Stop", "health server", err))
|
||||
// Auto-unregister
|
||||
if d.opts.Registry != nil {
|
||||
if err := d.opts.Registry.Unregister(d.opts.RegistryEntry.Code, d.opts.RegistryEntry.Daemon); err != nil {
|
||||
errs = append(errs, coreerr.E("Daemon.Stop", "registry", err))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -177,9 +177,11 @@ func (d *Daemon) Stop() error {
|
|||
}
|
||||
}
|
||||
|
||||
// Auto-unregister
|
||||
if d.opts.Registry != nil {
|
||||
_ = d.opts.Registry.Unregister(d.opts.RegistryEntry.Code, d.opts.RegistryEntry.Daemon)
|
||||
if d.health != nil {
|
||||
d.health.SetReady(false)
|
||||
if err := d.health.Stop(shutdownCtx); err != nil {
|
||||
errs = append(errs, coreerr.E("Daemon.Stop", "health server", err))
|
||||
}
|
||||
}
|
||||
|
||||
d.running = false
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue