Unverified Commit 9a862610 authored by Darren Shepherd's avatar Darren Shepherd Committed by GitHub

Merge pull request #177 from erikwilson/systemd-notify

Enable systemd ready notification for k3s server
parents 7fbeafea 107b5f39
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
systemd "github.com/coreos/go-systemd/daemon"
"github.com/docker/docker/pkg/reexec" "github.com/docker/docker/pkg/reexec"
"github.com/natefinch/lumberjack" "github.com/natefinch/lumberjack"
"github.com/pkg/errors" "github.com/pkg/errors"
...@@ -113,6 +114,9 @@ func run(app *cli.Context, cfg *cmds.Server) error { ...@@ -113,6 +114,9 @@ func run(app *cli.Context, cfg *cmds.Server) error {
} }
logrus.Info("Starting k3s ", app.App.Version) logrus.Info("Starting k3s ", app.App.Version)
notifySocket := os.Getenv("NOTIFY_SOCKET")
os.Unsetenv("NOTIFY_SOCKET")
ctx := signal.SigTermCancelContext(context.Background()) ctx := signal.SigTermCancelContext(context.Background())
certs, err := server.StartServer(ctx, &serverConfig) certs, err := server.StartServer(ctx, &serverConfig)
if err != nil { if err != nil {
...@@ -120,6 +124,10 @@ func run(app *cli.Context, cfg *cmds.Server) error { ...@@ -120,6 +124,10 @@ func run(app *cli.Context, cfg *cmds.Server) error {
} }
logrus.Info("k3s is up and running") logrus.Info("k3s is up and running")
if notifySocket != "" {
os.Setenv("NOTIFY_SOCKET", notifySocket)
systemd.SdNotify(true, "READY=1")
}
if cfg.DisableAgent { if cfg.DisableAgent {
<-ctx.Done() <-ctx.Done()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment