Skip to content

Commit

Permalink
service: add pidfile option
Browse files Browse the repository at this point in the history
  • Loading branch information
kardianos committed Feb 8, 2016
1 parent 5f98fcd commit 2dbca8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const (

optionRunWait = "RunWait"
optionReloadSignal = "ReloadSignal"
optionPIDFile = "PIDFile"
)

// Config provides the setup for a Service. The Name field is required.
Expand Down Expand Up @@ -112,6 +113,7 @@ type Config struct {
// * POSIX
// - 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.
Option KeyValue
}

Expand Down
3 changes: 3 additions & 0 deletions service_systemd_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ func (s *systemd) Install() error {
*Config
Path string
ReloadSignal string
PIDFile string
}{
s.Config,
path,
s.Option.string(optionReloadSignal, ""),
s.Option.string(optionPIDFile, ""),
}

err = s.template().Execute(f, to)
Expand Down Expand Up @@ -163,6 +165,7 @@ ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}}
{{if .WorkingDirectory}}WorkingDirectory={{.WorkingDirectory|cmd}}{{end}}
{{if .UserName}}User={{.UserName}}{{end}}
{{if .ReloadSignal}}ExecReload=/bin/kill -{{.ReloadSignal}} "$MAINPID"{{end}}
{{if .PIDFile}}PIDFile={{.PIDFile|cmd}}{{end}}
Restart=always
RestartSec=120
Expand Down

0 comments on commit 2dbca8f

Please sign in to comment.