systemd integration with container runtime for supporting sd_notify protocol

Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
This commit is contained in:
Shishir Mahajan
2015-07-15 10:50:22 -04:00
parent 1ed929f177
commit 27bfd1e2d1
+13
View File
@@ -67,6 +67,12 @@ func execContainer(context *cli.Context, spec *specs.LinuxSpec) (int, error) {
// default action is to execute a container // default action is to execute a container
func runAction(context *cli.Context) { func runAction(context *cli.Context) {
spec, err := loadSpec(context.Args().First()) spec, err := loadSpec(context.Args().First())
notifySocket := os.Getenv("NOTIFY_SOCKET")
if notifySocket != "" {
setupSdNotify(spec, notifySocket)
}
if err != nil { if err != nil {
fatal(err) fatal(err)
} }
@@ -82,6 +88,13 @@ func runAction(context *cli.Context) {
os.Exit(status) os.Exit(status)
} }
// If systemd is supporting sd_notify protocol, this function will add support
// for sd_notify protocol from within the container.
func setupSdNotify(spec *specs.LinuxSpec, notifySocket string) {
spec.Mounts = append(spec.Mounts, specs.Mount{Type: "bind", Source: notifySocket, Destination: notifySocket, Options: "bind"})
spec.Process.Env = append(spec.Process.Env, fmt.Sprintf("NOTIFY_SOCKET=%s", notifySocket))
}
func destroy(container libcontainer.Container) { func destroy(container libcontainer.Container) {
status, err := container.Status() status, err := container.Status()
if err != nil { if err != nil {