From f936b745b66de3cbbdf924a26bb35766afe5acba Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 26 Mar 2018 20:09:10 +0200 Subject: podman: new option --conmon-pidfile= so that it is possible to use systemd to automatically restart the container: [Service] Type=forking PIDFile=/run/awesome-service.pid ExecStart=/usr/bin/podman run --conmon-pidfile=/run/awesome-service.pid --name awesome -d IMAGE /usr/bin/do-something ExecStopPost=/usr/bin/podman rm awesome Restart=always Closes: https://github.com/projectatomic/libpod/issues/534 Signed-off-by: Giuseppe Scrivano Closes: #549 Approved by: rhatdan --- libpod/container.go | 2 ++ libpod/oci.go | 3 +++ libpod/options.go | 11 +++++++++++ 3 files changed, 16 insertions(+) (limited to 'libpod') diff --git a/libpod/container.go b/libpod/container.go index c2b07eb3f..965ac67fe 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -251,6 +251,8 @@ type ContainerConfig struct { CgroupParent string `json:"cgroupParent"` // LogPath log location LogPath string `json:"logPath"` + // File containing the conmon PID + ConmonPidFile string `json:"conmonPidFile,omitempty"` // TODO log options for log drivers } diff --git a/libpod/oci.go b/libpod/oci.go index 2ea3317d6..049d0817b 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -212,6 +212,9 @@ func (r *OCIRuntime) createContainer(ctr *Container, cgroupParent string) (err e args = append(args, "-p", filepath.Join(ctr.state.RunDir, "pidfile")) args = append(args, "-l", ctr.LogPath()) args = append(args, "--exit-dir", r.exitsDir) + if ctr.config.ConmonPidFile != "" { + args = append(args, "--conmon-pidfile", ctr.config.ConmonPidFile) + } args = append(args, "--socket-dir-path", r.socketsDir) if ctr.config.Spec.Process.Terminal { args = append(args, "-t") diff --git a/libpod/options.go b/libpod/options.go index 7cbe9afb4..987a37429 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -766,3 +766,14 @@ func WithHosts(hosts []string) CtrCreateOption { return nil } } + +// WithConmonPidFile specifies the path to the file that receives the pid of conmon +func WithConmonPidFile(path string) CtrCreateOption { + return func(ctr *Container) error { + if ctr.valid { + return ErrCtrFinalized + } + ctr.config.ConmonPidFile = path + return nil + } +} -- cgit v1.2.3-54-g00ecf