Skip to content

Commit

Permalink
Server systemd notify added similar to Consul. Resolves: hashicorp#7028
Browse files Browse the repository at this point in the history
  • Loading branch information
aphorise committed Aug 23, 2020
1 parent 1b43267 commit d0d28b0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"sync"
"time"

"github.com/hashicorp/consul/agent/systemd"
"github.com/hashicorp/errwrap"
"github.com/hashicorp/go-hclog"
log "github.com/hashicorp/go-hclog"
Expand Down Expand Up @@ -73,9 +74,17 @@ const (
storageTypeConsul = "consul"
)

// notifier is called after a successful JoinLAN.
type notifier interface {
Notify(string) error
}

type ServerCommand struct {
*BaseCommand

// joinLANNotifier is called after a successful JoinLAN.
NotifierSystemd notifier

AuditBackends map[string]audit.Factory
CredentialBackends map[string]logical.Factory
LogicalBackends map[string]logical.Factory
Expand Down Expand Up @@ -798,6 +807,9 @@ func (c *ServerCommand) processLogLevelAndFormat(config *server.Config) (log.Lev
}

func (c *ServerCommand) Run(args []string) int {

c.NotifierSystemd = &systemd.Notifier{}

f := c.Flags()

if err := f.Parse(args); err != nil {
Expand Down Expand Up @@ -1548,6 +1560,9 @@ CLUSTER_SYNTHESIS_COMPLETE:
for {
err := core.UnsealWithStoredKeys(context.Background())
if err == nil {
if notifyErr := c.NotifierSystemd.Notify(systemd.Ready); notifyErr != nil {
c.logger.Debug("server: systemd notify failed", notifyErr)
}
return
}

Expand Down

0 comments on commit d0d28b0

Please sign in to comment.