Commit 97710ced authored by Kevin Stock's avatar Kevin Stock Committed by Matt Holt

Add hook for instance startup (#1888)

Provides a new hook for plugins as a means to provide the current caddy.Instance when starting or restarting.
parent f878247a
......@@ -213,6 +213,9 @@ func (i *Instance) Restart(newCaddyfile Input) (*Instance, error) {
}
i.Stop()
// Execute instantiation events
EmitEvent(InstanceStartupEvent, newInst)
log.Println("[INFO] Reloading complete")
return newInst, nil
......
......@@ -140,6 +140,9 @@ func Run() {
mustLogFatalf("%v", err)
}
// Execute instantiation events
caddy.EmitEvent(caddy.InstanceStartupEvent, instance)
// Twiddle your thumbs
instance.Wait()
}
......
......@@ -233,9 +233,10 @@ type EventName string
// Define names for the various events
const (
StartupEvent EventName = "startup"
ShutdownEvent EventName = "shutdown"
CertRenewEvent EventName = "certrenew"
StartupEvent EventName = "startup"
ShutdownEvent EventName = "shutdown"
CertRenewEvent EventName = "certrenew"
InstanceStartupEvent EventName = "instancestartup"
)
// EventHook is a type which holds information about a startup hook plugin.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment