Skip to content

Commit

Permalink
feat: Allow to set StartLimitInterval and StartLimitBurst
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkheir committed Oct 21, 2024
1 parent 04689f7 commit a04e8f9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ const (
optionLaunchdConfig = "LaunchdConfig"
optionOpenRCScript = "OpenRCScript"

optionLogDirectory = "LogDirectory"
optionRestartSec = "RestartSec"
optionLogDirectory = "LogDirectory"
optionRestartSec = "RestartSec"
optionStartLimitInterval = "StartLimitInterval"
optionStartLimitBurst = "StartLimitBurst"
)

// Status represents service status as an byte value
Expand Down
8 changes: 6 additions & 2 deletions service_systemd_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ func (s *systemd) Install() error {
LogOutput bool
LogDirectory string
RestartSec string
StartLimitInterval string
StartLimitBurst int
}{
s.Config,
path,
Expand All @@ -185,6 +187,8 @@ func (s *systemd) Install() error {
s.Option.bool(optionLogOutput, optionLogOutputDefault),
s.Option.string(optionLogDirectory, defaultLogDirectory),
s.Option.string(optionRestartSec, "120s"),
s.Option.string(optionStartLimitInterval, "5"),
s.Option.int(optionStartLimitBurst, 10),
}

err = s.template().Execute(f, to)
Expand Down Expand Up @@ -307,8 +311,8 @@ ConditionFileIsExecutable={{.Path|cmdEscape}}
{{$dep}} {{end}}
[Service]
StartLimitInterval=5
StartLimitBurst=10
{{if .StartLimitInterval}}StartLimitInterval={{.StartLimitInterval}}{{end}}
{{if .StartLimitBurst}}StartLimitBurst={{.StartLimitBurst}}{{end}}
ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}}
{{if .ChRoot}}RootDirectory={{.ChRoot|cmd}}{{end}}
{{if .WorkingDirectory}}WorkingDirectory={{.WorkingDirectory|cmdEscape}}{{end}}
Expand Down

0 comments on commit a04e8f9

Please sign in to comment.