summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gobgpd/main.go4
-rw-r--r--server/server.go6
2 files changed, 9 insertions, 1 deletions
diff --git a/gobgpd/main.go b/gobgpd/main.go
index 7a3b3ef2..307372f1 100644
--- a/gobgpd/main.go
+++ b/gobgpd/main.go
@@ -35,7 +35,7 @@ func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
sigCh := make(chan os.Signal, 1)
- signal.Notify(sigCh, syscall.SIGHUP)
+ signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGTERM)
var opts struct {
ConfigFile string `short:"f" long:"config-file" description:"specifying a config file"`
@@ -206,6 +206,8 @@ func main() {
case syscall.SIGHUP:
log.Info("reload the config file")
reloadCh <- true
+ case syscall.SIGKILL, syscall.SIGTERM:
+ bgpServer.Shutdown()
}
}
}
diff --git a/server/server.go b/server/server.go
index 6a3962d2..4cabc7b9 100644
--- a/server/server.go
+++ b/server/server.go
@@ -710,6 +710,12 @@ func (server *BgpServer) PeerUpdate(peer config.Neighbor) {
server.updatedPeerCh <- peer
}
+func (server *BgpServer) Shutdown() {
+ for _, p := range server.neighborMap {
+ p.fsm.adminStateCh <- ADMIN_STATE_DOWN
+ }
+}
+
func (server *BgpServer) UpdatePolicy(policy config.RoutingPolicy) {
server.policyUpdateCh <- policy
}