Merge: * systemd service file: fix boot priority: start AGH after network is online

Close #1048

* commit '127cca0c83d9afc95c6957c5745d36e770e0d19b':
  * systemd service file: fix boot priority: start AGH after network is online
This commit is contained in:
Simon Zolin 2019-10-09 15:36:00 +03:00
commit e7463b380d
1 changed files with 31 additions and 0 deletions

View File

@ -139,6 +139,10 @@ func configureService(c *service.Config) {
// POSIX
// Redirect StdErr & StdOut to files.
c.Option["LogOutput"] = true
// Add "After=" setting for systemd service file, because we must be started only after network is online
// Set "RestartSec" to 10
c.Option["SystemdScript"] = systemdScript
}
// cleanupService called on the service uninstall, cleans up additional files if needed
@ -185,3 +189,30 @@ var launchdConfig = `<?xml version='1.0' encoding='UTF-8'?>
</dict>
</plist>
`
// Note: we should keep it in sync with the template from service_systemd_linux.go file
const systemdScript = `[Unit]
Description={{.Description}}
ConditionFileIsExecutable={{.Path|cmdEscape}}
After=syslog.target network-online.target
[Service]
StartLimitInterval=5
StartLimitBurst=10
ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}}
{{if .ChRoot}}RootDirectory={{.ChRoot|cmd}}{{end}}
{{if .WorkingDirectory}}WorkingDirectory={{.WorkingDirectory|cmdEscape}}{{end}}
{{if .UserName}}User={{.UserName}}{{end}}
{{if .ReloadSignal}}ExecReload=/bin/kill -{{.ReloadSignal}} "$MAINPID"{{end}}
{{if .PIDFile}}PIDFile={{.PIDFile|cmd}}{{end}}
{{if and .LogOutput .HasOutputFileSupport -}}
StandardOutput=file:/var/log/{{.Name}}.out
StandardError=file:/var/log/{{.Name}}.err
{{- end}}
Restart=always
RestartSec=10
EnvironmentFile=-/etc/sysconfig/{{.Name}}
[Install]
WantedBy=multi-user.target
`