summaryrefslogtreecommitdiff
path: root/pkg/systemd/generate/pods.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/systemd/generate/pods.go')
-rw-r--r--pkg/systemd/generate/pods.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/pkg/systemd/generate/pods.go b/pkg/systemd/generate/pods.go
index f4cc31c8e..f2d04dadc 100644
--- a/pkg/systemd/generate/pods.go
+++ b/pkg/systemd/generate/pods.go
@@ -30,6 +30,8 @@ type podInfo struct {
StopTimeout uint
// RestartPolicy of the systemd unit (e.g., no, on-failure, always).
RestartPolicy string
+ // RestartSec of the systemd unit. Configures the time to sleep before restarting a service.
+ RestartSec uint
// PIDFile of the service. Required for forking services. Must point to the
// PID of the associated conmon process.
PIDFile string
@@ -89,6 +91,9 @@ Before={{{{- range $index, $value := .RequiredServices -}}}}{{{{if $index}}}} {{
[Service]
Environment={{{{.EnvVariable}}}}=%n
Restart={{{{.RestartPolicy}}}}
+{{{{- if .RestartSec}}}}
+RestartSec={{{{.RestartSec}}}}
+{{{{- end}}}}
TimeoutStopSec={{{{.TimeoutStopSec}}}}
{{{{- if .ExecStartPre1}}}}
ExecStartPre={{{{.ExecStartPre1}}}}
@@ -103,7 +108,7 @@ PIDFile={{{{.PIDFile}}}}
Type=forking
[Install]
-WantedBy=multi-user.target default.target
+WantedBy=default.target
`
// PodUnits generates systemd units for the specified pod and its containers.
@@ -242,6 +247,10 @@ func executePodTemplate(info *podInfo, options entities.GenerateSystemdOptions)
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()