daemon_linux.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package main
  2. import (
  3. cdcgroups "github.com/containerd/cgroups/v3"
  4. systemdDaemon "github.com/coreos/go-systemd/v22/daemon"
  5. "github.com/docker/docker/daemon/config"
  6. "github.com/docker/docker/pkg/sysinfo"
  7. "github.com/pkg/errors"
  8. )
  9. // preNotifyReady sends a message to the host when the API is active, but before the daemon is
  10. func preNotifyReady() {
  11. }
  12. // notifyReady sends a message to the host when the server is ready to be used
  13. func notifyReady() {
  14. // Tell the init daemon we are accepting requests
  15. go systemdDaemon.SdNotify(false, systemdDaemon.SdNotifyReady)
  16. }
  17. // notifyStopping sends a message to the host when the server is shutting down
  18. func notifyStopping() {
  19. go systemdDaemon.SdNotify(false, systemdDaemon.SdNotifyStopping)
  20. }
  21. func validateCPURealtimeOptions(config *config.Config) error {
  22. if config.CPURealtimePeriod == 0 && config.CPURealtimeRuntime == 0 {
  23. return nil
  24. }
  25. if cdcgroups.Mode() == cdcgroups.Unified {
  26. return errors.New("daemon-scoped cpu-rt-period and cpu-rt-runtime are not implemented for cgroup v2")
  27. }
  28. if !sysinfo.New().CPURealtime {
  29. return errors.New("daemon-scoped cpu-rt-period and cpu-rt-runtime are not supported by the kernel")
  30. }
  31. return nil
  32. }