From ecb70f1573aeab5020a991e99236999f942dd792 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 31 Mar 2023 16:56:40 +0200 Subject: [PATCH] Send readiness notification to systemd --- cmd/ipfs-cluster-service/daemon.go | 11 +++++++++++ go.mod | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/ipfs-cluster-service/daemon.go b/cmd/ipfs-cluster-service/daemon.go index e05b19cc..3dfc0880 100644 --- a/cmd/ipfs-cluster-service/daemon.go +++ b/cmd/ipfs-cluster-service/daemon.go @@ -31,6 +31,7 @@ import ( ma "github.com/multiformats/go-multiaddr" + sddaemon "github.com/coreos/go-systemd/v22/daemon" errors "github.com/pkg/errors" cli "github.com/urfave/cli" ) @@ -105,6 +106,16 @@ func daemon(c *cli.Context) error { // will realize). go bootstrap(ctx, cluster, bootstraps) + // send readiness notification to systemd + go func() { + select { + case <-ctx.Done(): + return + case <-cluster.Ready(): + sddaemon.SdNotify(false, sddaemon.SdNotifyReady) + } + }() + return cmdutils.HandleSignals(ctx, cancel, cluster, host, dht, store) } diff --git a/go.mod b/go.mod index fefbeb56..dd95dc6d 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ require ( contrib.go.opencensus.io/exporter/prometheus v0.4.2 github.com/blang/semver v3.5.1+incompatible github.com/cockroachdb/pebble v0.0.0-20230227185959-8285e8dd5c08 + github.com/coreos/go-systemd/v22 v22.5.0 github.com/dgraph-io/badger v1.6.2 github.com/dgraph-io/badger/v3 v3.2103.5 github.com/dustin/go-humanize v1.0.1 @@ -86,7 +87,6 @@ require ( github.com/cockroachdb/redact v1.0.8 // indirect github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect github.com/containerd/cgroups v1.0.4 // indirect - github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 // indirect github.com/cskr/pubsub v1.0.2 // indirect