mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Merge pull request #48518 from thaJeztah/windows_daemon_nofatal
cmd/dockerd: windows: don't use Fatal log to prevent early exit
This commit is contained in:
@@ -227,7 +227,9 @@ func (cli *daemonCLI) start(ctx context.Context) (err error) {
|
||||
}()
|
||||
|
||||
// Notify that the API is active, but before daemon is set up.
|
||||
preNotifyReady()
|
||||
if err := preNotifyReady(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
const otelServiceNameEnv = "OTEL_SERVICE_NAME"
|
||||
if _, ok := os.LookupEnv(otelServiceNameEnv); !ok {
|
||||
|
||||
@@ -3,7 +3,8 @@ package main
|
||||
import "github.com/docker/docker/daemon/config"
|
||||
|
||||
// preNotifyReady sends a message to the host when the API is active, but before the daemon is
|
||||
func preNotifyReady() {
|
||||
func preNotifyReady() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// notifyReady sends a message to the host when the server is ready to be used
|
||||
|
||||
@@ -26,7 +26,8 @@ func setPlatformOptions(conf *config.Config) error {
|
||||
}
|
||||
|
||||
// preNotifyReady sends a message to the host when the API is active, but before the daemon is
|
||||
func preNotifyReady() {
|
||||
func preNotifyReady() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// notifyReady sends a message to the host when the server is ready to be used
|
||||
|
||||
@@ -41,15 +41,16 @@ func setDefaultUmask() error {
|
||||
}
|
||||
|
||||
// preNotifyReady sends a message to the host when the API is active, but before the daemon is
|
||||
func preNotifyReady() {
|
||||
func preNotifyReady() error {
|
||||
// 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 {
|
||||
err := service.started()
|
||||
if err != nil {
|
||||
log.G(context.TODO()).Fatal(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// notifyReady sends a message to the host when the server is ready to be used
|
||||
@@ -63,9 +64,6 @@ func notifyStopping() {
|
||||
// notifyShutdown is called after the daemon shuts down but before the process exits.
|
||||
func notifyShutdown(err error) {
|
||||
if service != nil {
|
||||
if err != nil {
|
||||
log.G(context.TODO()).Fatal(err)
|
||||
}
|
||||
service.stopped(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,11 @@ func runDaemon(ctx context.Context, cli *daemonCLI) error {
|
||||
}
|
||||
|
||||
err = cli.start(ctx)
|
||||
if service != nil {
|
||||
// When running as a service, log the error, so that it's sent to
|
||||
// the event-log.
|
||||
log.G(ctx).Error(err)
|
||||
}
|
||||
notifyShutdown(err)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user