-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make systemd and its dependencies optional via 'no_systemd' build tag
Running under systemd requires lots of special code that contributes to ca. 10 percent (ca. 1 MB) to the binary size. This is only needed on targets that might run systemd - there're dozens of distros, let alone embedded/edge devices or special images (eg. cluster worker nodes) that do not and never will run systemd, thus do not need that code at all. It's not just about reducing memory consumption, but also having over 10.000 lines of code less to audit. In order not to change default behaviour, introducing an inverse build tag, 'no_systemd', for explicitly opting out from systemd special handlings. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
- Loading branch information
Showing
5 changed files
with
44 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// +build linux,no_systemd | ||
|
||
package main | ||
|
||
import ( | ||
"errors" | ||
"os" | ||
) | ||
|
||
func sdGetListenFDs() ([]*os.File) { | ||
return nil | ||
} | ||
|
||
func sdDetectUID() (int, error) { | ||
return -1, errors.New("no lennartix") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// +build linux,!no_systemd | ||
|
||
package main | ||
|
||
import ( | ||
"os" | ||
"github.com/coreos/go-systemd/v22/activation" | ||
"github.com/opencontainers/runc/libcontainer/cgroups/systemd" | ||
) | ||
|
||
func sdGetListenFDs() []*os.File { | ||
// Support on-demand socket activation by passing file descriptors into the container init process. | ||
listenFDs := []*os.File{} | ||
if os.Getenv("LISTEN_FDS") != "" { | ||
listenFDs = activation.Files(false) | ||
} | ||
return listenFDs | ||
} | ||
|
||
func sdDetectUID() (int, error) { | ||
return systemd.DetectUID() | ||
} |