settings: reload through SIGHUP
This commit is contained in:
parent
ab67146c0f
commit
3a372b85c5
|
@ -6,8 +6,10 @@ import (
|
|||
"encoding/json"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path"
|
||||
"time"
|
||||
"syscall"
|
||||
|
||||
"gopkg.in/fsnotify.v1"
|
||||
)
|
||||
|
@ -117,6 +119,20 @@ func LoadAndWatchSettings(settingsPath string, reload func (FICSettings)) {
|
|||
}
|
||||
}
|
||||
|
||||
// Register SIGHUP
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, syscall.SIGHUP)
|
||||
go func(){
|
||||
for range c {
|
||||
log.Println("SIGHUP received, reloading settings...")
|
||||
if config, err := ReadSettings(settingsPath); err != nil {
|
||||
log.Println("ERROR: Unable to read challenge settings:", err)
|
||||
} else {
|
||||
reload(config)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// Watch the configuration file
|
||||
if watcher, err := fsnotify.NewWatcher(); err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
Loading…
Reference in New Issue