mirror of
https://github.com/caddyserver/caddy.git
synced 2025-03-21 12:59:26 +01:00
on: Allow nonblocking command with no other arguments (#1913)
This commit is contained in:
parent
c4dfbb9956
commit
99625ae3f6
2 changed files with 2 additions and 1 deletions
|
@ -16,7 +16,7 @@ func (cfg *Config) Hook(event caddy.EventName, info interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
nonblock := false
|
nonblock := false
|
||||||
if len(cfg.Args) > 1 && cfg.Args[len(cfg.Args)-1] == "&" {
|
if len(cfg.Args) >= 1 && cfg.Args[len(cfg.Args)-1] == "&" {
|
||||||
// Run command in background; non-blocking
|
// Run command in background; non-blocking
|
||||||
nonblock = true
|
nonblock = true
|
||||||
cfg.Args = cfg.Args[:len(cfg.Args)-1]
|
cfg.Args = cfg.Args[:len(cfg.Args)-1]
|
||||||
|
|
|
@ -33,6 +33,7 @@ func TestHook(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{name: "blocking", event: caddy.InstanceStartupEvent, command: "mkdir", args: []string{osSenitiveTestDir}, shouldErr: false, shouldRemoveErr: false},
|
{name: "blocking", event: caddy.InstanceStartupEvent, command: "mkdir", args: []string{osSenitiveTestDir}, shouldErr: false, shouldRemoveErr: false},
|
||||||
{name: "nonBlocking", event: caddy.ShutdownEvent, command: "mkdir", args: []string{osSenitiveTestDir, "&"}, shouldErr: false, shouldRemoveErr: true},
|
{name: "nonBlocking", event: caddy.ShutdownEvent, command: "mkdir", args: []string{osSenitiveTestDir, "&"}, shouldErr: false, shouldRemoveErr: true},
|
||||||
|
{name: "nonBlocking2", event: caddy.ShutdownEvent, command: "echo", args: []string{"&"}, shouldErr: false, shouldRemoveErr: true},
|
||||||
{name: "nonExistent", event: caddy.CertRenewEvent, command: strconv.Itoa(int(time.Now().UnixNano())), shouldErr: true, shouldRemoveErr: true},
|
{name: "nonExistent", event: caddy.CertRenewEvent, command: strconv.Itoa(int(time.Now().UnixNano())), shouldErr: true, shouldRemoveErr: true},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue