caddy: Run OnShutdown callbacks before instance Stop() calls (#2320)

- see https://github.com/coredns/coredns/issues/1666#issuecomment-380624422
This commit is contained in:
Ruslan Drozhdzh 2018-10-30 03:25:36 +03:00 committed by Matt Holt
parent 86060ef9b4
commit 3ce3f3a96a

View file

@ -248,16 +248,16 @@ func (i *Instance) Restart(newCaddyfile Input) (*Instance, error) {
}
// success! stop the old instance
err = i.Stop()
if err != nil {
return i, err
}
for _, shutdownFunc := range i.onShutdown {
err = shutdownFunc()
if err != nil {
return i, err
}
}
err = i.Stop()
if err != nil {
return i, err
}
// Execute instantiation events
EmitEvent(InstanceStartupEvent, newInst)