From b480c15a9c4b2be41439e3648cb0701963d8efbf Mon Sep 17 00:00:00 2001 From: Carl Baldwin Date: Wed, 24 Jul 2019 09:02:01 -0600 Subject: Factor out stopServer --- cmd/gobgpd/main.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'cmd') diff --git a/cmd/gobgpd/main.go b/cmd/gobgpd/main.go index e0fcda33..a1351ff1 100644 --- a/cmd/gobgpd/main.go +++ b/cmd/gobgpd/main.go @@ -167,10 +167,7 @@ func main() { for { select { case <-sigCh: - bgpServer.StopBgp(context.Background(), &api.StopBgpRequest{}) - if opts.UseSdNotify { - daemon.SdNotify(false, daemon.SdNotifyStopping) - } + stopServer(bgpServer, opts.UseSdNotify) return case newConfig := <-configCh: c = config_api.UpdateConfig(bgpServer, c, newConfig) @@ -180,3 +177,10 @@ func main() { loop() } + +func stopServer(bgpServer *server.BgpServer, useSdNotify bool) { + bgpServer.StopBgp(context.Background(), &api.StopBgpRequest{}) + if useSdNotify { + daemon.SdNotify(false, daemon.SdNotifyStopping) + } +} -- cgit v1.2.3