mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-23 00:56:45 +01:00
onevent/startupshutdown: run command once per server block (#1934)
This commit is contained in:
parent
e5d04f9a96
commit
fc75527eb5
2 changed files with 12 additions and 6 deletions
|
@ -20,9 +20,12 @@ func setup(c *caddy.Controller) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register Event Hooks.
|
// Register Event Hooks.
|
||||||
for _, cfg := range config {
|
c.OncePerServerBlock(func() error {
|
||||||
caddy.RegisterEventHook("on-"+cfg.ID, cfg.Hook)
|
for _, cfg := range config {
|
||||||
}
|
caddy.RegisterEventHook("on-"+cfg.ID, cfg.Hook)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,12 @@ func Startup(c *caddy.Controller) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register Event Hooks.
|
// Register Event Hooks.
|
||||||
for _, cfg := range config {
|
c.OncePerServerBlock(func() error {
|
||||||
caddy.RegisterEventHook("on-"+cfg.ID, cfg.Hook)
|
for _, cfg := range config {
|
||||||
}
|
caddy.RegisterEventHook("on-"+cfg.ID, cfg.Hook)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
fmt.Println("NOTICE: Startup directive will be removed in a later version. Please migrate to 'on startup'")
|
fmt.Println("NOTICE: Startup directive will be removed in a later version. Please migrate to 'on startup'")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue