settings: reload through SIGHUP
This commit is contained in:
parent
ab67146c0f
commit
3a372b85c5
|
@ -6,8 +6,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"path"
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"gopkg.in/fsnotify.v1"
|
"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
|
// Watch the configuration file
|
||||||
if watcher, err := fsnotify.NewWatcher(); err != nil {
|
if watcher, err := fsnotify.NewWatcher(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user