mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-21 20:45:33 +03:00
Pull request: home: imp systemd unit script
Updates #3579. Squashed commit of the following: commit 9bb45127f625d4df2f4df8bd2ca4d6fe83557fc8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Sep 13 16:57:43 2021 +0300 all: imp chlog commit d2285cb6386acc5d6e835f85f118a959a33391e6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Sep 13 16:41:54 2021 +0300 home: imp systemd unit script
This commit is contained in:
parent
424f20da98
commit
53f7c0b2df
2 changed files with 26 additions and 7 deletions
|
@ -47,6 +47,8 @@ and this project adheres to
|
|||
|
||||
### Changed
|
||||
|
||||
- The `systemd` service script will now create the `/var/log` directory when it
|
||||
doesn't exist ([#3579]).
|
||||
- Items in allowed clients, disallowed clients, and blocked hosts lists must
|
||||
be unique ([#3419]).
|
||||
- The TLS private key previously saved as a string isn't shown in API responses
|
||||
|
@ -191,6 +193,7 @@ In this release, the schema version has changed from 10 to 12.
|
|||
[#3551]: https://github.com/AdguardTeam/AdGuardHome/issues/3551
|
||||
[#3564]: https://github.com/AdguardTeam/AdGuardHome/issues/3564
|
||||
[#3568]: https://github.com/AdguardTeam/AdGuardHome/issues/3568
|
||||
[#3579]: https://github.com/AdguardTeam/AdGuardHome/issues/3579
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -310,10 +310,15 @@ func configureService(c *service.Config) {
|
|||
// This key is used to start the job as soon as it has been loaded. For daemons this means execution at boot time, for agents execution at login.
|
||||
c.Option["RunAtLoad"] = true
|
||||
|
||||
// POSIX
|
||||
// POSIX / systemd
|
||||
|
||||
// Redirect StdErr & StdOut to files.
|
||||
// Redirect stderr and stdout to files. Make sure we always restart.
|
||||
// Start only once network is up on Linux/systemd.
|
||||
c.Option["LogOutput"] = true
|
||||
c.Option["Restart"] = "always"
|
||||
c.Dependencies = []string{
|
||||
"After=syslog.target network-online.target",
|
||||
}
|
||||
|
||||
// Use modified service file templates.
|
||||
c.Option["SystemdScript"] = systemdScript
|
||||
|
@ -368,17 +373,26 @@ var launchdConfig = `<?xml version='1.0' encoding='UTF-8'?>
|
|||
</plist>
|
||||
`
|
||||
|
||||
// Note: we should keep it in sync with the template from service_systemd_linux.go file
|
||||
// Add "After=" setting for systemd service file, because we must be started only after network is online
|
||||
// Set "RestartSec" to 10
|
||||
// systemdScript is an improved version of the systemd script originally from
|
||||
// the systemdScript constant in file service_systemd_linux.go in module
|
||||
// github.com/kardianos/service. The following changes have been made:
|
||||
//
|
||||
// 1. The RestartSec setting is set to a lower value of 10 to make sure we
|
||||
// always restart quickly.
|
||||
//
|
||||
// 2. The ExecStartPre setting is added to make sure that the log directory is
|
||||
// always created to prevent the 209/STDOUT errors.
|
||||
//
|
||||
const systemdScript = `[Unit]
|
||||
Description={{.Description}}
|
||||
ConditionFileIsExecutable={{.Path|cmdEscape}}
|
||||
After=syslog.target network-online.target
|
||||
{{range $i, $dep := .Dependencies}}
|
||||
{{$dep}} {{end}}
|
||||
|
||||
[Service]
|
||||
StartLimitInterval=5
|
||||
StartLimitBurst=10
|
||||
ExecStartPre=mkdir -p /var/log/
|
||||
ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}}
|
||||
{{if .ChRoot}}RootDirectory={{.ChRoot|cmd}}{{end}}
|
||||
{{if .WorkingDirectory}}WorkingDirectory={{.WorkingDirectory|cmdEscape}}{{end}}
|
||||
|
@ -389,7 +403,9 @@ ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}}
|
|||
StandardOutput=file:/var/log/{{.Name}}.out
|
||||
StandardError=file:/var/log/{{.Name}}.err
|
||||
{{- end}}
|
||||
Restart=always
|
||||
{{if gt .LimitNOFILE -1 }}LimitNOFILE={{.LimitNOFILE}}{{end}}
|
||||
{{if .Restart}}Restart={{.Restart}}{{end}}
|
||||
{{if .SuccessExitStatus}}SuccessExitStatus={{.SuccessExitStatus}}{{end}}
|
||||
RestartSec=10
|
||||
EnvironmentFile=-/etc/sysconfig/{{.Name}}
|
||||
|
||||
|
|
Loading…
Reference in a new issue