service: add pidfile option
This commit is contained in:
@@ -81,6 +81,7 @@ const (
|
|||||||
|
|
||||||
optionRunWait = "RunWait"
|
optionRunWait = "RunWait"
|
||||||
optionReloadSignal = "ReloadSignal"
|
optionReloadSignal = "ReloadSignal"
|
||||||
|
optionPIDFile = "PIDFile"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config provides the setup for a Service. The Name field is required.
|
// Config provides the setup for a Service. The Name field is required.
|
||||||
@@ -112,6 +113,7 @@ type Config struct {
|
|||||||
// * POSIX
|
// * POSIX
|
||||||
// - RunWait func() (wait for SIGNAL) - Do not install signal but wait for this function to return.
|
// - RunWait func() (wait for SIGNAL) - Do not install signal but wait for this function to return.
|
||||||
// - ReloadSignal string () [USR1, ...] - Signal to send on reaload.
|
// - ReloadSignal string () [USR1, ...] - Signal to send on reaload.
|
||||||
|
// - PIDFile string () [/run/prog.pid] - Location of the PID file.
|
||||||
Option KeyValue
|
Option KeyValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,10 +81,12 @@ func (s *systemd) Install() error {
|
|||||||
*Config
|
*Config
|
||||||
Path string
|
Path string
|
||||||
ReloadSignal string
|
ReloadSignal string
|
||||||
|
PIDFile string
|
||||||
}{
|
}{
|
||||||
s.Config,
|
s.Config,
|
||||||
path,
|
path,
|
||||||
s.Option.string(optionReloadSignal, ""),
|
s.Option.string(optionReloadSignal, ""),
|
||||||
|
s.Option.string(optionPIDFile, ""),
|
||||||
}
|
}
|
||||||
|
|
||||||
err = s.template().Execute(f, to)
|
err = s.template().Execute(f, to)
|
||||||
@@ -163,6 +165,7 @@ ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}}
|
|||||||
{{if .WorkingDirectory}}WorkingDirectory={{.WorkingDirectory|cmd}}{{end}}
|
{{if .WorkingDirectory}}WorkingDirectory={{.WorkingDirectory|cmd}}{{end}}
|
||||||
{{if .UserName}}User={{.UserName}}{{end}}
|
{{if .UserName}}User={{.UserName}}{{end}}
|
||||||
{{if .ReloadSignal}}ExecReload=/bin/kill -{{.ReloadSignal}} "$MAINPID"{{end}}
|
{{if .ReloadSignal}}ExecReload=/bin/kill -{{.ReloadSignal}} "$MAINPID"{{end}}
|
||||||
|
{{if .PIDFile}}PIDFile={{.PIDFile|cmd}}{{end}}
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=120
|
RestartSec=120
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user