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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user