mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
daemon: un-export IsRunningSystemd()
This utility was added after 19.03, and is only used in the daemon code itself, so we can un-export it, until there's an external use for it. Also updated the description, because the runc code already copied it from coreos/go-systemd, so better to describe the actual source. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
a8a769f04f
commit
e7ba5cacc6
1 changed files with 9 additions and 3 deletions
|
@ -638,14 +638,20 @@ func UsingSystemd(config *config.Config) bool {
|
|||
return true
|
||||
}
|
||||
// On cgroup v2 hosts, default to systemd driver
|
||||
if getCD(config) == "" && cgroups.Mode() == cgroups.Unified && IsRunningSystemd() {
|
||||
if getCD(config) == "" && cgroups.Mode() == cgroups.Unified && isRunningSystemd() {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRunningSystemd is from https://github.com/opencontainers/runc/blob/46be7b612e2533c494e6a251111de46d8e286ed5/libcontainer/cgroups/systemd/common.go#L27-L33
|
||||
func IsRunningSystemd() bool {
|
||||
// isRunningSystemd checks whether the host was booted with systemd as its init
|
||||
// system. This functions similarly to systemd's `sd_booted(3)`: internally, it
|
||||
// checks whether /run/systemd/system/ exists and is a directory.
|
||||
// http://www.freedesktop.org/software/systemd/man/sd_booted.html
|
||||
//
|
||||
// NOTE: This function comes from package github.com/coreos/go-systemd/util
|
||||
// It was borrowed here to avoid a dependency on cgo.
|
||||
func isRunningSystemd() bool {
|
||||
fi, err := os.Lstat("/run/systemd/system")
|
||||
if err != nil {
|
||||
return false
|
||||
|
|
Loading…
Add table
Reference in a new issue