mirror of
https://github.com/adnanh/webhook.git
synced 2025-06-01 10:12:28 +00:00
parent
cc5cbae14f
commit
c6c270c7dd
2 changed files with 11 additions and 3 deletions
|
@ -44,7 +44,9 @@ Usage of webhook:
|
||||||
Use any of the above specified flags to override their default behavior.
|
Use any of the above specified flags to override their default behavior.
|
||||||
|
|
||||||
# Live reloading hooks
|
# 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
|
```bash
|
||||||
kill -USR1 webhookpid
|
kill -USR1 webhookpid
|
||||||
|
|
||||||
|
kill -HUP webhookpid
|
||||||
```
|
```
|
||||||
|
|
10
signals.go
10
signals.go
|
@ -14,6 +14,7 @@ func setupSignals() {
|
||||||
|
|
||||||
signals = make(chan os.Signal, 1)
|
signals = make(chan os.Signal, 1)
|
||||||
signal.Notify(signals, syscall.SIGUSR1)
|
signal.Notify(signals, syscall.SIGUSR1)
|
||||||
|
signal.Notify(signals, syscall.SIGHUP)
|
||||||
|
|
||||||
go watchForSignals()
|
go watchForSignals()
|
||||||
}
|
}
|
||||||
|
@ -23,11 +24,16 @@ func watchForSignals() {
|
||||||
|
|
||||||
for {
|
for {
|
||||||
sig := <-signals
|
sig := <-signals
|
||||||
if sig == syscall.SIGUSR1 {
|
switch sig {
|
||||||
|
case syscall.SIGUSR1:
|
||||||
log.Println("caught USR1 signal")
|
log.Println("caught USR1 signal")
|
||||||
|
|
||||||
reloadAllHooks()
|
reloadAllHooks()
|
||||||
} else {
|
case syscall.SIGHUP:
|
||||||
|
log.Println("caught HUP signal")
|
||||||
|
|
||||||
|
reloadAllHooks()
|
||||||
|
default:
|
||||||
log.Printf("caught unhandled signal %+v\n", sig)
|
log.Printf("caught unhandled signal %+v\n", sig)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue