summaryrefslogtreecommitdiff
path: root/pkg/systemd/generate/systemdgen.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/systemd/generate/systemdgen.go')
-rw-r--r--pkg/systemd/generate/systemdgen.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/pkg/systemd/generate/systemdgen.go b/pkg/systemd/generate/systemdgen.go
index 404347828..4410e1395 100644
--- a/pkg/systemd/generate/systemdgen.go
+++ b/pkg/systemd/generate/systemdgen.go
@@ -80,6 +80,8 @@ const containerTemplate = `# {{.ServiceName}}.service
[Unit]
Description=Podman {{.ServiceName}}.service
Documentation=man:podman-generate-systemd(1)
+Wants=network.target
+After=network-online.target
{{- if .BoundToServices}}
RefuseManualStart=yes
RefuseManualStop=yes
@@ -94,11 +96,11 @@ Before={{- range $index, $value := .RequiredServices -}}{{if $index}} {{end}}{{
[Service]
Restart={{.RestartPolicy}}
{{- if .New}}
-ExecStartPre=/usr/bin/rm -f /%t/%n-pid /%t/%n-cid
+ExecStartPre=/usr/bin/rm -f %t/%n-pid %t/%n-cid
ExecStart={{.RunCommand}}
-ExecStop={{.Executable}} stop --ignore --cidfile /%t/%n-cid {{if (ge .StopTimeout 0)}}-t {{.StopTimeout}}{{end}}
-ExecStopPost={{.Executable}} rm --ignore -f --cidfile /%t/%n-cid
-PIDFile=/%t/%n-pid
+ExecStop={{.Executable}} stop --ignore --cidfile %t/%n-cid {{if (ge .StopTimeout 0)}}-t {{.StopTimeout}}{{end}}
+ExecStopPost={{.Executable}} rm --ignore -f --cidfile %t/%n-cid
+PIDFile=%t/%n-pid
{{- else}}
ExecStart={{.Executable}} start {{.ContainerName}}
ExecStop={{.Executable}} stop {{if (ge .StopTimeout 0)}}-t {{.StopTimeout}}{{end}} {{.ContainerName}}
@@ -108,7 +110,7 @@ KillMode=none
Type=forking
[Install]
-WantedBy=multi-user.target`
+WantedBy=multi-user.target default.target`
// Options include different options to control the unit file generation.
type Options struct {
@@ -158,8 +160,8 @@ func CreateContainerSystemdUnit(info *ContainerInfo, opts Options) (string, erro
command := []string{
info.Executable,
"run",
- "--conmon-pidfile", "/%t/%n-pid",
- "--cidfile", "/%t/%n-cid",
+ "--conmon-pidfile", "%t/%n-pid",
+ "--cidfile", "%t/%n-cid",
"--cgroups=no-conmon",
}
command = append(command, info.CreateCommand[index:]...)