summaryrefslogtreecommitdiffhomepage
path: root/config/serve.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-03-16 06:20:11 -0700
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-03-16 06:20:11 -0700
commitb65dd149f03d099dc9023db9e2277f8abd90a29b (patch)
treeae577af53b21ea488544014fc4fd8bd3665b84fa /config/serve.go
parentb290ec7e7eddf90be0bdb0aa00a387c1a2ebb8aa (diff)
server: move SIGHUP handling to config file reader goroutine
the main goroutine doesn't need to do so. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'config/serve.go')
-rw-r--r--config/serve.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/config/serve.go b/config/serve.go
index 8c7d833c..4b5fbbe9 100644
--- a/config/serve.go
+++ b/config/serve.go
@@ -3,7 +3,10 @@ package config
import (
log "github.com/Sirupsen/logrus"
"github.com/spf13/viper"
+ "os"
+ "os/signal"
"reflect"
+ "syscall"
)
type BgpConfigSet struct {
@@ -11,11 +14,12 @@ type BgpConfigSet struct {
Policy RoutingPolicy
}
-func ReadConfigfileServe(path, format string, configCh chan BgpConfigSet, reloadCh chan bool) {
+func ReadConfigfileServe(path, format string, configCh chan BgpConfigSet) {
+ sigCh := make(chan os.Signal, 1)
+ signal.Notify(sigCh, syscall.SIGHUP)
+
cnt := 0
for {
- <-reloadCh
-
b := Bgp{}
v := viper.New()
v.SetConfigFile(path)
@@ -53,8 +57,11 @@ func ReadConfigfileServe(path, format string, configCh chan BgpConfigSet, reload
PolicyDefinitions: c.PolicyDefinitions,
},
}
+ select {
+ case <-sigCh:
+ log.Info("reload the config file")
+ }
continue
-
ERROR:
if cnt == 0 {
log.Fatal("can't read config file ", path, ", ", err)