summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>2020-12-23 03:49:35 +0900
committerGitHub <noreply@github.com>2020-12-23 03:49:35 +0900
commitd9a9aeea22331e9f110eeb4485af5470af7a0956 (patch)
treea3297bdb2bb6d083c5724983c7c315dd173383d0
parent4d6bc59f8102965258068facc2f064e69af0e688 (diff)
parentf3d0f7054dbc2e2bcd959cd4c7fc3a8fa097d525 (diff)
downloaddocker-d9a9aeea22331e9f110eeb4485af5470af7a0956.tar.gz
Merge pull request #41832 from thaJeztah/sd_notify_stopping
cmd/dockerd: sd_notify STOPPING=1 when shutting down
-rw-r--r--cmd/dockerd/daemon.go6
-rw-r--r--cmd/dockerd/daemon_freebsd.go12
-rw-r--r--cmd/dockerd/daemon_linux.go13
-rw-r--r--cmd/dockerd/daemon_windows.go12
4 files changed, 29 insertions, 14 deletions
diff --git a/cmd/dockerd/daemon.go b/cmd/dockerd/daemon.go
index 96c31943fa..7fe8a6cbc6 100644
--- a/cmd/dockerd/daemon.go
+++ b/cmd/dockerd/daemon.go
@@ -184,7 +184,7 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
}, logrus.StandardLogger())
// Notify that the API is active, but before daemon is set up.
- preNotifySystem()
+ preNotifyReady()
pluginStore := plugin.NewStore()
@@ -242,13 +242,15 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
go cli.api.Wait(serveAPIWait)
// after the daemon is done setting up we can notify systemd api
- notifySystem()
+ notifyReady()
// Daemon is fully initialized and handling API traffic
// Wait for serve API to complete
errAPI := <-serveAPIWait
c.Cleanup()
+ // notify systemd that we're shutting down
+ notifyStopping()
shutdownDaemon(d)
// Stop notification processing and any background processes
diff --git a/cmd/dockerd/daemon_freebsd.go b/cmd/dockerd/daemon_freebsd.go
index 6d013b8103..1bb49047c7 100644
--- a/cmd/dockerd/daemon_freebsd.go
+++ b/cmd/dockerd/daemon_freebsd.go
@@ -1,9 +1,13 @@
package main
-// preNotifySystem sends a message to the host when the API is active, but before the daemon is
-func preNotifySystem() {
+// preNotifyReady sends a message to the host when the API is active, but before the daemon is
+func preNotifyReady() {
}
-// notifySystem sends a message to the host when the server is ready to be used
-func notifySystem() {
+// notifyReady sends a message to the host when the server is ready to be used
+func notifyReady() {
+}
+
+// notifyStopping sends a message to the host when the server is shutting down
+func notifyStopping() {
}
diff --git a/cmd/dockerd/daemon_linux.go b/cmd/dockerd/daemon_linux.go
index 1e7a2ca64e..aade57a8d3 100644
--- a/cmd/dockerd/daemon_linux.go
+++ b/cmd/dockerd/daemon_linux.go
@@ -2,12 +2,17 @@ package main
import systemdDaemon "github.com/coreos/go-systemd/v22/daemon"
-// preNotifySystem sends a message to the host when the API is active, but before the daemon is
-func preNotifySystem() {
+// preNotifyReady sends a message to the host when the API is active, but before the daemon is
+func preNotifyReady() {
}
-// notifySystem sends a message to the host when the server is ready to be used
-func notifySystem() {
+// notifyReady sends a message to the host when the server is ready to be used
+func notifyReady() {
// Tell the init daemon we are accepting requests
go systemdDaemon.SdNotify(false, systemdDaemon.SdNotifyReady)
}
+
+// notifyStopping sends a message to the host when the server is shutting down
+func notifyStopping() {
+ go systemdDaemon.SdNotify(false, systemdDaemon.SdNotifyStopping)
+}
diff --git a/cmd/dockerd/daemon_windows.go b/cmd/dockerd/daemon_windows.go
index 2d74531d46..1a9c50b21f 100644
--- a/cmd/dockerd/daemon_windows.go
+++ b/cmd/dockerd/daemon_windows.go
@@ -27,8 +27,8 @@ func getDaemonConfDir(root string) (string, error) {
return filepath.Join(root, `\config`), nil
}
-// preNotifySystem sends a message to the host when the API is active, but before the daemon is
-func preNotifySystem() {
+// preNotifyReady sends a message to the host when the API is active, but before the daemon is
+func preNotifyReady() {
// start the service now to prevent timeouts waiting for daemon to start
// but still (eventually) complete all requests that are sent after this
if service != nil {
@@ -39,8 +39,12 @@ func preNotifySystem() {
}
}
-// notifySystem sends a message to the host when the server is ready to be used
-func notifySystem() {
+// notifyReady sends a message to the host when the server is ready to be used
+func notifyReady() {
+}
+
+// notifyStopping sends a message to the host when the server is shutting down
+func notifyStopping() {
}
// notifyShutdown is called after the daemon shuts down but before the process exits.