Added LimitNOFILE option in systemd configuration (#94)
Co-authored-by: Daniel Theophanes <kardianos@gmail.com>
This commit is contained in:
@@ -83,6 +83,8 @@ const (
|
|||||||
optionRunWait = "RunWait"
|
optionRunWait = "RunWait"
|
||||||
optionReloadSignal = "ReloadSignal"
|
optionReloadSignal = "ReloadSignal"
|
||||||
optionPIDFile = "PIDFile"
|
optionPIDFile = "PIDFile"
|
||||||
|
optionLimitNOFILE = "LimitNOFILE"
|
||||||
|
optionLimitNOFILEDefault = -1 // -1 = don't set in configuration
|
||||||
optionRestart = "Restart"
|
optionRestart = "Restart"
|
||||||
|
|
||||||
optionSuccessExitStatus = "SuccessExitStatus"
|
optionSuccessExitStatus = "SuccessExitStatus"
|
||||||
@@ -147,6 +149,9 @@ type Config struct {
|
|||||||
// - Restart string (always) - How shall service be restarted.
|
// - Restart string (always) - How shall service be restarted.
|
||||||
// - SuccessExitStatus string () - The list of exit status that shall be considered as successful,
|
// - SuccessExitStatus string () - The list of exit status that shall be considered as successful,
|
||||||
// in addition to the default ones.
|
// in addition to the default ones.
|
||||||
|
// * Linux (systemd)
|
||||||
|
// - LimitNOFILE int - Maximum open files (ulimit -n) (https://serverfault.com/questions/628610/increasing-nproc-for-processes-launched-by-systemd-on-centos-7)
|
||||||
|
|
||||||
Option KeyValue
|
Option KeyValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,6 +156,7 @@ func (s *systemd) Install() error {
|
|||||||
HasOutputFileSupport bool
|
HasOutputFileSupport bool
|
||||||
ReloadSignal string
|
ReloadSignal string
|
||||||
PIDFile string
|
PIDFile string
|
||||||
|
LimitNOFILE int
|
||||||
Restart string
|
Restart string
|
||||||
SuccessExitStatus string
|
SuccessExitStatus string
|
||||||
LogOutput bool
|
LogOutput bool
|
||||||
@@ -165,6 +166,7 @@ func (s *systemd) Install() error {
|
|||||||
s.hasOutputFileSupport(),
|
s.hasOutputFileSupport(),
|
||||||
s.Option.string(optionReloadSignal, ""),
|
s.Option.string(optionReloadSignal, ""),
|
||||||
s.Option.string(optionPIDFile, ""),
|
s.Option.string(optionPIDFile, ""),
|
||||||
|
s.Option.int(optionLimitNOFILE, optionLimitNOFILEDefault),
|
||||||
s.Option.string(optionRestart, "always"),
|
s.Option.string(optionRestart, "always"),
|
||||||
s.Option.string(optionSuccessExitStatus, ""),
|
s.Option.string(optionSuccessExitStatus, ""),
|
||||||
s.Option.bool(optionLogOutput, optionLogOutputDefault),
|
s.Option.bool(optionLogOutput, optionLogOutputDefault),
|
||||||
@@ -288,6 +290,7 @@ ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}}
|
|||||||
StandardOutput=file:/var/log/{{.Name}}.out
|
StandardOutput=file:/var/log/{{.Name}}.out
|
||||||
StandardError=file:/var/log/{{.Name}}.err
|
StandardError=file:/var/log/{{.Name}}.err
|
||||||
{{- end}}
|
{{- end}}
|
||||||
|
{{if gt .LimitNOFILE -1 }}LimitNOFILE={{.LimitNOFILE}}{{end}}
|
||||||
{{if .Restart}}Restart={{.Restart}}{{end}}
|
{{if .Restart}}Restart={{.Restart}}{{end}}
|
||||||
{{if .SuccessExitStatus}}SuccessExitStatus={{.SuccessExitStatus}}{{end}}
|
{{if .SuccessExitStatus}}SuccessExitStatus={{.SuccessExitStatus}}{{end}}
|
||||||
RestartSec=120
|
RestartSec=120
|
||||||
|
|||||||
Reference in New Issue
Block a user