Merge pull request #378 from moorereason/feature/sighup

Add SIGHUP support
This commit is contained in:
Adnan Hajdarević
2019-12-26 12:46:12 +01:00
committed by GitHub
2 changed files with 11 additions and 3 deletions
+3 -1
View File
@@ -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
```
+8 -2
View File
@@ -14,6 +14,7 @@ func setupSignals() {
signals = make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGUSR1)
signal.Notify(signals, syscall.SIGHUP)
go watchForSignals()
}
@@ -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)
}
}