Skip to content

Commit

Permalink
feat: Add support for systemd notify
Browse files Browse the repository at this point in the history
- Integrated systemd notification support using github.com/coreos/go-systemd/v22/daemon.
- Updated manager/runner.go to signal readiness to systemd.
- Modified .golangci.yml to include github.com/coreos/go-systemd in linters-settings.
- Updated dependencies in go.mod and go.sum for github.com/coreos/go-systemd/v22 v22.5.0.
  • Loading branch information
dyudin0821 committed Jun 18, 2024
1 parent 53a5f43 commit 219f740
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ linters-settings:
- github.com/pkg/errors
- github.com/stretchr/testify/assert
- github.com/stretchr/testify/require
- github.com/coreos/go-systemd

run:
timeout: 10m
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ require (
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/coreos/go-systemd/v22 v22.5.0
github.com/fatih/color v1.17.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
github.com/google/uuid v1.3.0 // indirect
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ github.com/cenkalti/backoff/v3 v3.2.2/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4r
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
Expand All @@ -50,6 +52,7 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw=
github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down
7 changes: 7 additions & 0 deletions manager/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/hashicorp/consul-template/template"
"github.com/hashicorp/consul-template/watch"

"github.com/coreos/go-systemd/v22/daemon"
"github.com/hashicorp/go-multierror"
)

Expand Down Expand Up @@ -311,6 +312,12 @@ func (r *Runner) Start() {
log.Printf("[DEBUG] (runner) all templates rendered")
// Enable quiescence for all templates if we have specified wait
// intervals.

_, err := daemon.SdNotify(false, daemon.SdNotifyReady)
if err != nil {
log.Printf("[WARN] (runner) failed to signal readiness to systemd: %v", err)
}

NEXT_Q:
for _, t := range r.templates {
if _, ok := r.quiescenceMap[t.ID()]; ok {
Expand Down

0 comments on commit 219f740

Please sign in to comment.