summaryrefslogtreecommitdiffhomepage
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
parentb7189a6acaaa50b5dd00e462ea5b57db0dc079e8 (diff)
cmd/gobgp: use sd_notify protocol to notify the status change to systemd
-rw-r--r--Gopkg.lock38
-rw-r--r--Gopkg.toml4
-rw-r--r--cmd/gobgpd/main.go15
3 files changed, 57 insertions, 0 deletions
diff --git a/Gopkg.lock b/Gopkg.lock
index 5dcff56d..fcc6cd32 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -18,6 +18,14 @@
revision = "1fca145dffbcaa8fe914309b1ec0cfc67500fe61"
[[projects]]
+ branch = "master"
+ digest = "1:af4e29ce389815fea4fdc4b44f746321e1d27fbdf03a14f3350d8fdd7e0707ce"
+ name = "github.com/coreos/go-systemd"
+ packages = ["daemon"]
+ pruneopts = ""
+ revision = "93d5ec2c7f76e57b4f3cb9fa4ee4e3ea43f3e5c9"
+
+[[projects]]
digest = "1:56c130d885a4aacae1dd9c7b71cfe39912c7ebc1ff7d2b46083c8812996dc43b"
name = "github.com/davecgh/go-spew"
packages = ["spew"]
@@ -139,6 +147,25 @@
revision = "d0303fe809921458f417bcf828397a65db30a7e4"
[[projects]]
+ digest = "1:6a97b2d47774dd7a34cd89cb796023f8995538f0f00a23c9d7bfe7ad637e9601"
+ name = "github.com/osrg/gobgp"
+ packages = [
+ "api",
+ "internal/pkg/apiutil",
+ "internal/pkg/config",
+ "internal/pkg/table",
+ "internal/pkg/zebra",
+ "pkg/packet/bgp",
+ "pkg/packet/bmp",
+ "pkg/packet/mrt",
+ "pkg/packet/rtr",
+ "pkg/server",
+ ]
+ pruneopts = ""
+ revision = "f4643d090f3546060157dff83231e4aa89e7f483"
+ version = "v2.2.0"
+
+[[projects]]
digest = "1:049b5bee78dfdc9628ee0e557219c41f683e5b06c5a5f20eaba0105ccc586689"
name = "github.com/pelletier/go-buffruneio"
packages = ["."]
@@ -349,6 +376,7 @@
input-imports = [
"github.com/BurntSushi/toml",
"github.com/armon/go-radix",
+ "github.com/coreos/go-systemd/daemon",
"github.com/dgryski/go-farm",
"github.com/eapache/channels",
"github.com/golang/protobuf/proto",
@@ -358,6 +386,16 @@
"github.com/golang/protobuf/ptypes/timestamp",
"github.com/jessevdk/go-flags",
"github.com/kr/pretty",
+ "github.com/osrg/gobgp/api",
+ "github.com/osrg/gobgp/internal/pkg/apiutil",
+ "github.com/osrg/gobgp/internal/pkg/config",
+ "github.com/osrg/gobgp/internal/pkg/table",
+ "github.com/osrg/gobgp/internal/pkg/zebra",
+ "github.com/osrg/gobgp/pkg/packet/bgp",
+ "github.com/osrg/gobgp/pkg/packet/bmp",
+ "github.com/osrg/gobgp/pkg/packet/mrt",
+ "github.com/osrg/gobgp/pkg/packet/rtr",
+ "github.com/osrg/gobgp/pkg/server",
"github.com/satori/go.uuid",
"github.com/sirupsen/logrus",
"github.com/sirupsen/logrus/hooks/syslog",
diff --git a/Gopkg.toml b/Gopkg.toml
index 442e34cf..4044bdfb 100644
--- a/Gopkg.toml
+++ b/Gopkg.toml
@@ -76,3 +76,7 @@
[[constraint]]
name = "google.golang.org/grpc"
version = "1.5.1"
+
+[[constraint]]
+ branch = "master"
+ name = "github.com/coreos/go-systemd"
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