Merge pull request #129 from shishir-a412ed/sd_notify
systemd integration with container runtime for supporting sd_notify protocol
This commit is contained in:
commit
6c86daa6c9
13
run.go
13
run.go
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue