From ae4e7a0703146539f18021aff635d12ca2d59862 Mon Sep 17 00:00:00 2001 From: Carl Baldwin Date: Tue, 30 Jul 2019 16:16:38 -0600 Subject: Remove loop function --- cmd/gobgpd/main.go | 58 +++++++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 31 deletions(-) (limited to 'cmd') diff --git a/cmd/gobgpd/main.go b/cmd/gobgpd/main.go index 1bdcb449..dc2f4fc0 100644 --- a/cmd/gobgpd/main.go +++ b/cmd/gobgpd/main.go @@ -170,45 +170,41 @@ func main() { signal.Notify(sigCh, syscall.SIGHUP) - loop := func() { - initialConfig, err := config.ReadConfigFile(opts.ConfigFile, opts.ConfigType) - if err != nil { - log.WithFields(log.Fields{ - "Topic": "Config", - "Error": err, - }).Fatalf("Can't read config file %s", opts.ConfigFile) - } + initialConfig, err := config.ReadConfigFile(opts.ConfigFile, opts.ConfigType) + if err != nil { log.WithFields(log.Fields{ "Topic": "Config", - }).Info("Finished reading the config file") - - c := config.ApplyInitialConfig(bgpServer, initialConfig, opts.GracefulRestart) - for { - select { - case sig := <-sigCh: - if sig != syscall.SIGHUP { - stopServer(bgpServer, opts.UseSdNotify) - return - } + "Error": err, + }).Fatalf("Can't read config file %s", opts.ConfigFile) + } + log.WithFields(log.Fields{ + "Topic": "Config", + }).Info("Finished reading the config file") + + c := config.ApplyInitialConfig(bgpServer, initialConfig, opts.GracefulRestart) + for { + select { + case sig := <-sigCh: + if sig != syscall.SIGHUP { + stopServer(bgpServer, opts.UseSdNotify) + return + } + log.WithFields(log.Fields{ + "Topic": "Config", + }).Info("Reload the config file") + newConfig, err := config.ReadConfigFile(opts.ConfigFile, opts.ConfigType) + if err != nil { log.WithFields(log.Fields{ "Topic": "Config", - }).Info("Reload the config file") - newConfig, err := config.ReadConfigFile(opts.ConfigFile, opts.ConfigType) - if err != nil { - log.WithFields(log.Fields{ - "Topic": "Config", - "Error": err, - }).Warningf("Can't read config file %s", opts.ConfigFile) - continue - } - - c = config.UpdateConfig(bgpServer, c, newConfig) + "Error": err, + }).Warningf("Can't read config file %s", opts.ConfigFile) + continue } + + c = config.UpdateConfig(bgpServer, c, newConfig) } } - - loop() } func stopServer(bgpServer *server.BgpServer, useSdNotify bool) { -- cgit v1.2.3