mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-28 14:43:48 +03:00
caddy: move EmitEvent(InstanceStartupEvent, instance) (#2161)
* caddy: move EmitEvent(InstanceStartupEvent, instance) * caddy: update SupportedEvents
This commit is contained in:
parent
f3a4f46d78
commit
771dcf3d40
4 changed files with 10 additions and 7 deletions
4
caddy.go
4
caddy.go
|
@ -498,6 +498,10 @@ func Start(cdyfile Input) (*Instance, error) {
|
|||
if pidErr := writePidFile(); pidErr != nil {
|
||||
log.Printf("[ERROR] Could not write pidfile: %v", pidErr)
|
||||
}
|
||||
|
||||
// Execute instantiation events
|
||||
EmitEvent(InstanceStartupEvent, inst)
|
||||
|
||||
return inst, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -160,9 +160,6 @@ func Run() {
|
|||
mustLogFatalf("%v", err)
|
||||
}
|
||||
|
||||
// Execute instantiation events
|
||||
caddy.EmitEvent(caddy.InstanceStartupEvent, instance)
|
||||
|
||||
// Begin telemetry (these are no-ops if telemetry disabled)
|
||||
telemetry.Set("caddy_version", appVersion)
|
||||
telemetry.Set("num_listeners", len(instance.Servers()))
|
||||
|
|
|
@ -14,7 +14,8 @@ type Config struct {
|
|||
|
||||
// SupportedEvents is a map of supported events.
|
||||
var SupportedEvents = map[string]caddy.EventName{
|
||||
"startup": caddy.InstanceStartupEvent,
|
||||
"shutdown": caddy.ShutdownEvent,
|
||||
"certrenew": caddy.CertRenewEvent,
|
||||
"startup": caddy.StartupEvent,
|
||||
"instance_startup": caddy.InstanceStartupEvent,
|
||||
"shutdown": caddy.ShutdownEvent,
|
||||
"certrenew": caddy.CertRenewEvent,
|
||||
}
|
||||
|
|
|
@ -45,7 +45,8 @@ func TestCommandParse(t *testing.T) {
|
|||
}{
|
||||
{name: "noInput", input: `on`, shouldErr: true},
|
||||
{name: "nonExistent", input: "on xyz cmd arg", shouldErr: true},
|
||||
{name: "startup", input: `on startup cmd arg1 arg2`, shouldErr: false, config: hook.Config{Event: caddy.InstanceStartupEvent, Command: "cmd", Args: []string{"arg1", "arg2"}}},
|
||||
{name: "startup", input: `on startup cmd arg1 arg2`, shouldErr: false, config: hook.Config{Event: caddy.StartupEvent, Command: "cmd", Args: []string{"arg1", "arg2"}}},
|
||||
{name: "instance_startup", input: `on instance_startup cmd arg1 arg2`, shouldErr: false, config: hook.Config{Event: caddy.InstanceStartupEvent, Command: "cmd", Args: []string{"arg1", "arg2"}}},
|
||||
{name: "shutdown", input: `on shutdown cmd arg1 arg2 &`, shouldErr: false, config: hook.Config{Event: caddy.ShutdownEvent, Command: "cmd", Args: []string{"arg1", "arg2", "&"}}},
|
||||
{name: "certrenew", input: `on certrenew cmd arg1 arg2`, shouldErr: false, config: hook.Config{Event: caddy.CertRenewEvent, Command: "cmd", Args: []string{"arg1", "arg2"}}},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue