From 3ce3f3a96af53e3fa0d8d84cfd82b7364728301e Mon Sep 17 00:00:00 2001 From: Ruslan Drozhdzh <30860269+rdrozhdzh@users.noreply.github.com> Date: Tue, 30 Oct 2018 03:25:36 +0300 Subject: [PATCH] caddy: Run OnShutdown callbacks before instance Stop() calls (#2320) - see https://github.com/coredns/coredns/issues/1666#issuecomment-380624422 --- caddy.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/caddy.go b/caddy.go index 1adf01134..3a2a0ccef 100644 --- a/caddy.go +++ b/caddy.go @@ -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)