diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-03-06 16:38:49 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-03-06 16:45:17 +0900 |
commit | 87790c1149ff93576ba06aa879cd7ad953587964 (patch) | |
tree | 780546782c10cc71fde185cdb756573da4c25e9d /gobgpd | |
parent | 5f317e778f548fa696bfd57e314306d87a593fdb (diff) |
gobgpd: add dry-run mode
use `-d` option to check configuration
close #741
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'gobgpd')
-rw-r--r-- | gobgpd/main.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/gobgpd/main.go b/gobgpd/main.go index b8e024f4..89f3126a 100644 --- a/gobgpd/main.go +++ b/gobgpd/main.go @@ -19,6 +19,7 @@ import ( log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus/hooks/syslog" "github.com/jessevdk/go-flags" + p "github.com/kr/pretty" "github.com/osrg/gobgp/config" ops "github.com/osrg/gobgp/openswitch" "github.com/osrg/gobgp/server" @@ -49,6 +50,7 @@ func main() { Ops bool `long:"openswitch" description:"openswitch mode"` GrpcPort int `short:"g" long:"grpc-port" description:"grpc port" default:"50051"` GracefulRestart bool `short:"r" long:"graceful-restart" description:"flag restart-state in graceful-restart capability"` + Dry bool `short:"d" long:"dry-run" description:"check configuration"` } _, err := flags.Parse(&opts) if err != nil { @@ -150,10 +152,20 @@ func main() { log.SetFormatter(&log.JSONFormatter{}) } - log.Info("gobgpd started") - configCh := make(chan config.BgpConfigSet) reloadCh := make(chan bool) + if opts.Dry { + go config.ReadConfigfileServe(opts.ConfigFile, opts.ConfigType, configCh, reloadCh) + reloadCh <- true + c := <-configCh + if opts.LogLevel == "debug" { + p.Println(c) + } + os.Exit(0) + } + + log.Info("gobgpd started") + bgpServer := server.NewBgpServer() if opts.Ops { m, err := ops.NewOpsManager(bgpServer.GrpcReqCh) |