mirror of
https://github.com/kardianos/service.git
synced 2025-10-06 01:07:01 +08:00
Systemd/dep (#165)
* support the dependency config for linux systemd * remote the binary file incorrectly added
This commit is contained in:

committed by
Daniel Theophanes

parent
56787a3ea0
commit
0e5bec1b9e
@@ -67,6 +67,9 @@ func main() {
|
|||||||
Name: "GoServiceExampleLogging",
|
Name: "GoServiceExampleLogging",
|
||||||
DisplayName: "Go Service Example for Logging",
|
DisplayName: "Go Service Example for Logging",
|
||||||
Description: "This is an example Go service that outputs log messages.",
|
Description: "This is an example Go service that outputs log messages.",
|
||||||
|
Dependencies: []string{
|
||||||
|
"Requires=network.target",
|
||||||
|
"After=network-online.target syslog.target"},
|
||||||
}
|
}
|
||||||
|
|
||||||
prg := &program{}
|
prg := &program{}
|
||||||
|
@@ -111,7 +111,13 @@ type Config struct {
|
|||||||
Executable string
|
Executable string
|
||||||
|
|
||||||
// Array of service dependencies.
|
// Array of service dependencies.
|
||||||
// Not yet implemented on Linux or OS X.
|
// Not yet fully implemented on Linux or OS X:
|
||||||
|
// 1. Support linux-systemd dependencies, just put each full line as the
|
||||||
|
// element of the string array, such as
|
||||||
|
// "After=network.target syslog.target"
|
||||||
|
// "Requires=syslog.target"
|
||||||
|
// Note, such lines will be directly appended into the [Unit] of
|
||||||
|
// the generated service config file, will not check their correctness.
|
||||||
Dependencies []string
|
Dependencies []string
|
||||||
|
|
||||||
// The following fields are not supported on Windows.
|
// The following fields are not supported on Windows.
|
||||||
|
@@ -228,6 +228,9 @@ func (s *systemd) Restart() error {
|
|||||||
const systemdScript = `[Unit]
|
const systemdScript = `[Unit]
|
||||||
Description={{.Description}}
|
Description={{.Description}}
|
||||||
ConditionFileIsExecutable={{.Path|cmdEscape}}
|
ConditionFileIsExecutable={{.Path|cmdEscape}}
|
||||||
|
{{range .Dependencies}}
|
||||||
|
{{.}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
StartLimitInterval=5
|
StartLimitInterval=5
|
||||||
|
Reference in New Issue
Block a user