Files
moby/daemon/command/docker_windows.go
Sebastiaan van Stijn 99c81194be daemon: windows: remove stray error log on service shutdown
runDaemon would unconditionally send an error event if the daemon
was running as a system service;

    Run New-Item -ItemType Directory -Force -Path ".\bundles" | Out-Null
    2026-06-08T03:31:52.1865738Z [Information] Starting up
    2026-06-08T03:31:52.3160498Z [Information] OTEL tracing is not configured, using no-op tracer provider
    2026-06-08T03:31:52.5037110Z [Information] Windows default isolation mode: process
    2026-06-08T03:31:52.7212058Z [Information] Loading containers: start.
    2026-06-08T03:31:52.7345902Z [Information] [graphdriver] trying configured driver: windowsfilter
    2026-06-08T03:31:52.8920546Z [Information] Restoring containers: start.
    2026-06-08T03:31:52.9910057Z [Information] Restoring existing overlay networks from HNS into docker
    2026-06-08T03:31:53.8958218Z [Information] Loading containers: done.
    2026-06-08T03:31:53.9093383Z [Information] Docker daemon [storage-driver=windowsfilter containerd-snapshotter=false version=29.1.5 commit=3b01d641]
    2026-06-08T03:31:53.9103431Z [Information] Initializing buildkit
    2026-06-08T03:31:54.3243456Z [Information] Completed buildkit initialization
    2026-06-08T03:31:54.4878293Z [Information] Daemon has completed initialization
    2026-06-08T03:31:54.4881959Z [Information] API listen on //./pipe/docker_engine
    2026-06-08T03:47:45.7182269Z [Information] Processing signal 'terminated'
    2026-06-08T03:47:45.7203206Z [Information] Daemon shutdown complete
    Error: 2026-06-08T03:47:45.7206236Z [Error] <nil>

If debug was enabled, it would log this error twice (once as error, and once as debug).

Let's make this a single log, and only an error if there was one. Note that this may still
be redundant, as `daemonCLI.start` also logs this error;
https://github.com/moby/moby/blob/4c19a015750813d4a289879e1e387d374d7403cd/daemon/command/daemon.go#L127-L134

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-06-12 12:45:14 +02:00

46 lines
1.1 KiB
Go

package command
import (
"context"
"io"
"github.com/Microsoft/go-winio/pkg/etwlogrus"
"github.com/containerd/log"
)
func runDaemon(ctx context.Context, cli *daemonCLI) error {
// On Windows, this may be launching as a service or with an option to
// register the service.
stop, runAsService, err := initService(ctx, cli)
if err != nil {
return err
}
if stop {
return nil
}
if runAsService {
// If Windows SCM manages the service - no need for PID files
cli.Config.Pidfile = ""
}
err = cli.start(ctx)
notifyShutdown(ctx, err)
return err
}
func initLogging(stdout, _ io.Writer) {
// Maybe there is a historic reason why on non-Windows, stderr is used
// for output. However, on Windows it makes no sense and there is no need.
log.L.Logger.SetOutput(stdout)
// Provider ID: {6996f090-c5de-5082-a81e-5841acc3a635}
// Hook isn't closed explicitly, as it will exist until process exit.
// GUID is generated based on name - see Microsoft/go-winio/tools/etw-provider-gen.
if hook, err := etwlogrus.NewHook("Moby"); err == nil {
log.L.Logger.AddHook(hook)
}
return
}