mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
cmd/dockerd: sd_notify STOPPING=1 when shutting down
Signal systemd when we start shutting down to complement the "READY" notify
that was originally implemented in 97088ebef7
From [sd_notify(3)](https://www.freedesktop.org/software/systemd/man/sd_notify.html#STOPPING=1)
> STOPPING=1
> Tells the service manager that the service is beginning its shutdown. This is useful
> to allow the service manager to track the service's internal state, and present it to
> the user.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
aa1ada6b2a
commit
f3d0f7054d
4 changed files with 29 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue