Merge pull request #129 from shishir-a412ed/sd_notify

systemd integration with container runtime for supporting sd_notify protocol
This commit is contained in:
Mrunal Patel 2015-07-27 09:44:55 -07:00
commit 6c86daa6c9
1 changed files with 13 additions and 0 deletions

13
run.go
View File

@ -67,6 +67,12 @@ func execContainer(context *cli.Context, spec *specs.LinuxSpec) (int, error) {
// default action is to execute a container
func runAction(context *cli.Context) {
spec, err := loadSpec(context.Args().First())
notifySocket := os.Getenv("NOTIFY_SOCKET")
if notifySocket != "" {
setupSdNotify(spec, notifySocket)
}
if err != nil {
fatal(err)
}
@ -82,6 +88,13 @@ func runAction(context *cli.Context) {
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) {
status, err := container.Status()
if err != nil {