Refactor signal handling and Windows support

This commit drops webhook_windows.go in favor of simply pulling out the
signal handling code to separate files.
This commit is contained in:
Cameron Moore 2015-10-29 11:17:15 -05:00
parent 409b441c31
commit 1c319a7a08
4 changed files with 42 additions and 312 deletions

34
signals.go Normal file
View file

@ -0,0 +1,34 @@
// +build !windows
package main
import (
"log"
"os"
"os/signal"
"syscall"
)
func setupSignals() {
log.Printf("setting up os signal watcher\n")
signals = make(chan os.Signal, 1)
signal.Notify(signals, syscall.SIGUSR1)
go watchForSignals()
}
func watchForSignals() {
log.Println("os signal watcher ready")
for {
sig := <-signals
if sig == syscall.SIGUSR1 {
log.Println("caught USR1 signal")
reloadHooks()
} else {
log.Printf("caught unhandled signal %+v\n", sig)
}
}
}