feat(config): add restart options for unit configuration

* include Restart, RestartSec, and RestartRetries fields
* update service file generation to support restart settings
* add tests for restart behavior in unit generation
This commit is contained in:
Hein
2026-04-10 09:38:45 +02:00
parent a273232303
commit b58373ad2f
3 changed files with 63 additions and 3 deletions

View File

@@ -20,8 +20,13 @@ Requires={{.}}{{end}}
Type=simple
ExecStart={{.ExecStart}}
ExecStop={{.ExecStop}}
{{- if .Unit.Restart}}
Restart=on-failure
RestartSec=5
RestartSec={{.Unit.RestartSec}}
{{- if gt .Unit.RestartRetries 0}}
StartLimitBurst={{.Unit.RestartRetries}}
{{- end}}
{{- end}}
[Install]
WantedBy=multi-user.target
@@ -38,8 +43,13 @@ After=default.target
Type=simple
ExecStart={{.ExecStart}}
ExecStop={{.ExecStop}}
{{- if .Unit.Restart}}
Restart=on-failure
RestartSec=5
RestartSec={{.Unit.RestartSec}}
{{- if gt .Unit.RestartRetries 0}}
StartLimitBurst={{.Unit.RestartRetries}}
{{- end}}
{{- end}}
[Install]
WantedBy=default.target