summaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
authorRobin Douine <r.douine@criteo.com>2019-03-08 16:27:09 +0100
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2019-03-14 21:51:08 +0900
commit7bb72b7ad04b4e673811649e276b77c6f8e828c3 (patch)
tree79a63affc5d294b0bc1bbd35f20afec6f1b79ff6 /cmd
parentb7189a6acaaa50b5dd00e462ea5b57db0dc079e8 (diff)
cmd/gobgp: use sd_notify protocol to notify the status change to systemd
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gobgpd/main.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/cmd/gobgpd/main.go b/cmd/gobgpd/main.go
index 6fdc4858..0760ae3a 100644
--- a/cmd/gobgpd/main.go
+++ b/cmd/gobgpd/main.go
@@ -26,6 +26,7 @@ import (
"runtime"
"syscall"
+ "github.com/coreos/go-systemd/daemon"
"github.com/golang/protobuf/ptypes/any"
"github.com/jessevdk/go-flags"
"github.com/kr/pretty"
@@ -119,6 +120,7 @@ func main() {
Dry bool `short:"d" long:"dry-run" description:"check configuration"`
PProfHost string `long:"pprof-host" description:"specify the host that gobgpd listens on for pprof" default:"localhost:6060"`
PProfDisable bool `long:"pprof-disable" description:"disable pprof profiling"`
+ UseSdNotify bool `long:"sdnotify" description:"use sd_notify protocol"`
TLS bool `long:"tls" description:"enable TLS authentication for gRPC API"`
TLSCertFile string `long:"tls-cert-file" description:"The TLS cert file"`
TLSKeyFile string `long:"tls-key-file" description:"The TLS key file"`
@@ -205,6 +207,16 @@ func main() {
bgpServer := server.NewBgpServer(server.GrpcListenAddress(opts.GrpcHosts), server.GrpcOption(grpcOpts))
go bgpServer.Serve()
+ if opts.UseSdNotify {
+ if status, err := daemon.SdNotify(false, daemon.SdNotifyReady); !status {
+ if err != nil {
+ log.Warnf("Failed to send notification via sd_notify(): %s", err)
+ } else {
+ log.Warnf("The socket sd_notify() isn't available")
+ }
+ }
+ }
+
if opts.ConfigFile != "" {
go config.ReadConfigfileServe(opts.ConfigFile, opts.ConfigType, configCh)
}
@@ -215,6 +227,9 @@ func main() {
select {
case <-sigCh:
bgpServer.StopBgp(context.Background(), &api.StopBgpRequest{})
+ if opts.UseSdNotify {
+ daemon.SdNotify(false, daemon.SdNotifyStopping)
+ }
return
case newConfig := <-configCh:
var added, deleted, updated []config.Neighbor