Merge pull request #1898 from max-privatevoid/systemd-notify

Send readiness notification to systemd
This commit is contained in:
Hector Sanjuan 2023-04-15 00:55:54 +02:00 committed by GitHub
commit 6c3fc0e635
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -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)
}

2
go.mod
View File

@ -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