diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-06 08:10:59 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-06 08:10:59 +0900 |
commit | a79e962dea57be0904d95be9bf5de39ff24409d1 (patch) | |
tree | de726f2ec3bf26c726b5cdd17d965fd37cd88fa6 /config | |
parent | ed4e3422e2aef8545c5043d72733d82dcc1fe5b8 (diff) |
config: don't crash when failing to reload config file
gobgpd crashes when failing to read a config file at startup but
should not crash when failing to reload the config file.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'config')
-rw-r--r-- | config/serve.go | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/config/serve.go b/config/serve.go index a3beea30..d1f88788 100644 --- a/config/serve.go +++ b/config/serve.go @@ -12,24 +12,29 @@ type BgpConfigSet struct { } func ReadConfigfileServe(path string, configCh chan BgpConfigSet, reloadCh chan bool) { + cnt := 0 for { <-reloadCh b := Bgp{} + p := RoutingPolicy{} md, err := toml.DecodeFile(path, &b) if err == nil { err = SetDefaultConfigValues(md, &b) - } - if err != nil { - log.Fatal("can't read config file ", path, ", ", err) + if err == nil { + _, err = toml.DecodeFile(path, &p) + } } - p := RoutingPolicy{} - md, err = toml.DecodeFile(path, &p) if err != nil { - log.Fatal("can't read config file ", path, ", ", err) + if cnt == 0 { + log.Fatal("can't read config file ", path, ", ", err) + } else { + log.Warning("can't read config file ", path, ", ", err) + continue + } } - + cnt++ bgpConfig := BgpConfigSet{Bgp: b, Policy: p} configCh <- bgpConfig } |