Add restart-sec for container service files

Attempts to fix #16419

podman generate systemd --restart-sec pod
^now generates RestartSec= both in pod service file and in container service file.

podman generate systemd --restart-sec container
^now generates RestartSec= in container service file.

Signed-off-by: Veronika Fuxova <vfuxova@redhat.com>
This commit is contained in:
Veronika Fuxova
2022-11-10 13:03:50 +01:00
parent e86cef13a1
commit a2c43d4340
3 changed files with 62 additions and 0 deletions

View File

@ -28,6 +28,7 @@ type containerInfo struct {
NotifyAccess string
StopTimeout uint
RestartPolicy string
RestartSec uint
StartLimitBurst string
PIDFile string
ContainerIDFile string
@ -87,6 +88,9 @@ Environment={{{{- range $index, $value := .ExtraEnvs -}}}}{{{{if $index}}}} {{{{
Environment={{{{ $value }}}}{{{{end}}}}
{{{{- end}}}}
Restart={{{{.RestartPolicy}}}}
{{{{- if .RestartSec}}}}
RestartSec={{{{.RestartSec}}}}
{{{{- end}}}}
{{{{- if .StartLimitBurst}}}}
StartLimitBurst={{{{.StartLimitBurst}}}}
{{{{- end}}}}
@ -282,6 +286,10 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst
info.RestartPolicy = *options.RestartPolicy
}
if options.RestartSec != nil {
info.RestartSec = *options.RestartSec
}
// Make sure the executable is set.
if info.Executable == "" {
executable, err := os.Executable()