From 102a5f79d01bfb0da7cb495b03bd732c39f7090b Mon Sep 17 00:00:00 2001 From: Carl Baldwin Date: Wed, 24 Jul 2019 09:02:26 -0600 Subject: Move ReadConfigFileOnSighup to gobgpd main Reloading the config file on SIGHUP is behavior specific to gobgpd. Attempts to expose it through the config API was awkward and could make the api more confusing to use. This change moves that functionality up into the gobgpd main and out of the library. --- internal/pkg/config/serve.go | 42 ------------------------------------------ 1 file changed, 42 deletions(-) (limited to 'internal/pkg') diff --git a/internal/pkg/config/serve.go b/internal/pkg/config/serve.go index c1525525..1fe71332 100644 --- a/internal/pkg/config/serve.go +++ b/internal/pkg/config/serve.go @@ -1,10 +1,6 @@ package config import ( - "os" - "os/signal" - "syscall" - log "github.com/sirupsen/logrus" "github.com/spf13/viper" ) @@ -45,44 +41,6 @@ func ReadConfigfile(path, format string) (*BgpConfigSet, error) { return config, nil } -func ReadConfigfileServe(path, format string, configCh chan *BgpConfigSet) { - sigCh := make(chan os.Signal, 1) - signal.Notify(sigCh, syscall.SIGHUP) - - cnt := 0 - for { - c, err := ReadConfigfile(path, format) - if err != nil { - goto ERROR - } - if cnt == 0 { - log.WithFields(log.Fields{ - "Topic": "Config", - }).Info("Finished reading the config file") - } - cnt++ - configCh <- c - goto NEXT - ERROR: - if cnt == 0 { - log.WithFields(log.Fields{ - "Topic": "Config", - "Error": err, - }).Fatalf("Can't read config file %s", path) - } else { - log.WithFields(log.Fields{ - "Topic": "Config", - "Error": err, - }).Warningf("Can't read config file %s", path) - } - NEXT: - <-sigCh - log.WithFields(log.Fields{ - "Topic": "Config", - }).Info("Reload the config file") - } -} - func ConfigSetToRoutingPolicy(c *BgpConfigSet) *RoutingPolicy { return &RoutingPolicy{ DefinedSets: c.DefinedSets, -- cgit v1.2.3