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)