Skip to content

Commit

Permalink
pulling in kardianos#94
Browse files Browse the repository at this point in the history
  • Loading branch information
morfien101 committed Oct 15, 2019
1 parent 411be15 commit 9192318
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 7 additions & 4 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ const (
optionLogOutput = "LogOutput"
optionLogOutputDefault = false

optionRunWait = "RunWait"
optionReloadSignal = "ReloadSignal"
optionPIDFile = "PIDFile"
optionRestart = "Restart"
optionRunWait = "RunWait"
optionReloadSignal = "ReloadSignal"
optionPIDFile = "PIDFile"
optionRestart = "Restart"
optionLimitNOFILE = "LimitNOFILE"
optionLimitNOFILEDefault = -1 // -1 = don't set in configuration

optionSuccessExitStatus = "SuccessExitStatus"

Expand Down Expand Up @@ -141,6 +143,7 @@ type Config struct {
// - RunWait func() (wait for SIGNAL) - Do not install signal but wait for this function to return.
// - ReloadSignal string () [USR1, ...] - Signal to send on reaload.
// - PIDFile string () [/run/prog.pid] - Location of the PID file.
// - LimitNOFILE int - Maximum open files (ulimit -n) (https://serverfault.com/questions/628610/increasing-nproc-for-processes-launched-by-systemd-on-centos-7)
// - LogOutput bool (false) - Redirect StdErr & StdOut to files.
// - Restart string (always) - How shall service be restarted.
// - SuccessExitStatus string () - The list of exit status that shall be considered as successful,
Expand Down
3 changes: 3 additions & 0 deletions service_systemd_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func (s *systemd) Install() error {
Restart string
SuccessExitStatus string
LogOutput bool
LimitNOFILE int
}{
s.Config,
path,
Expand All @@ -161,6 +162,7 @@ func (s *systemd) Install() error {
s.Option.string(optionRestart, "always"),
s.Option.string(optionSuccessExitStatus, ""),
s.Option.bool(optionLogOutput, optionLogOutputDefault),
s.Option.int(optionLimitNOFILE, optionLimitNOFILEDefault),
}

err = s.template().Execute(f, to)
Expand Down Expand Up @@ -260,6 +262,7 @@ ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}}
{{if .UserName}}User={{.UserName}}{{end}}
{{if .ReloadSignal}}ExecReload=/bin/kill -{{.ReloadSignal}} "$MAINPID"{{end}}
{{if .PIDFile}}PIDFile={{.PIDFile|cmd}}{{end}}
{{if gt .LimitNOFILE -1 }}LimitNOFILE={{.LimitNOFILE}}{{end}}
{{if and .LogOutput .HasOutputFileSupport -}}
StandardOutput=file:/var/log/{{.Name}}.out
StandardError=file:/var/log/{{.Name}}.err
Expand Down

0 comments on commit 9192318

Please sign in to comment.