File: docker_windows.go

package info (click to toggle)
docker.io 28.5.2%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 69,048 kB
  • sloc: sh: 5,867; makefile: 863; ansic: 184; python: 162; asm: 159
file content (50 lines) | stat: -rw-r--r-- 1,224 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main

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(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)
	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
}

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
}