Skip to content

Commit

Permalink
Add SIGHUP support
Browse files Browse the repository at this point in the history
  • Loading branch information
moorereason committed Dec 25, 2019
1 parent cc5cbae commit c6c270c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion docs/Webhook-Parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ Usage of webhook:
Use any of the above specified flags to override their default behavior.

# Live reloading hooks
If you are running an OS that supports USR1 signal, you can use it to trigger hooks reload from hooks file, without restarting the webhook instance.
If you are running an OS that supports the HUP or USR1 signal, you can use it to trigger hooks reload from hooks file, without restarting the webhook instance.
```bash
kill -USR1 webhookpid

kill -HUP webhookpid
```
10 changes: 8 additions & 2 deletions signals.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func setupSignals() {

signals = make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGUSR1)
signal.Notify(signals, syscall.SIGHUP)

go watchForSignals()
}
Expand All @@ -23,11 +24,16 @@ func watchForSignals() {

for {
sig := <-signals
if sig == syscall.SIGUSR1 {
switch sig {
case syscall.SIGUSR1:
log.Println("caught USR1 signal")

reloadAllHooks()
} else {
case syscall.SIGHUP:
log.Println("caught HUP signal")

reloadAllHooks()
default:
log.Printf("caught unhandled signal %+v\n", sig)
}
}
Expand Down

0 comments on commit c6c270c

Please sign in to comment.