0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00

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.
This commit is contained in:
Kevin Stock 2017-10-01 19:36:23 -07:00 committed by Matt Holt
parent f878247a18
commit 97710ced7e
3 changed files with 10 additions and 3 deletions

View file

@ -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

View file

@ -140,6 +140,9 @@ func Run() {
mustLogFatalf("%v", err)
}
// Execute instantiation events
caddy.EmitEvent(caddy.InstanceStartupEvent, instance)
// Twiddle your thumbs
instance.Wait()
}

View file

@ -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.