Pull request 2237: 7053 journald Log

Updates #7053.

Squashed commit of the following:

commit f763a229660c00013fbd51cf7a3deabf00a01787
Merge: 06fc83d08 8432593be
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Mon Jun 17 17:52:11 2024 +0300

    Merge branch 'master' into 7053-journald-log

commit 06fc83d08e
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Jun 13 15:59:35 2024 +0300

    all: imp chlog

commit 1f57a7e84a
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Jun 11 20:36:55 2024 +0300

    all: imp chlog

commit 7c9a2547a8
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Jun 11 18:33:26 2024 +0300

    home: imp doc

commit 63731e7ba5
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Jun 11 18:27:31 2024 +0300

    home: imp systemd script
This commit is contained in:
Eugene Burkov 2024-06-17 18:33:16 +03:00
parent 8432593be1
commit 1c82be2950
2 changed files with 23 additions and 5 deletions

View File

@ -30,11 +30,29 @@ NOTE: Add new changes BELOW THIS COMMENT.
### Changed ### Changed
- Frontend rewritten in TypeScript. - Frontend rewritten in TypeScript.
- The `systemd`-based service now uses `journal` for logging by default. It
also doesn't create the `/var/log/` directory anymore ([#7053]).
**NOTE:** With an installed service for changes to take effect, you need to
reinstall the service using `-r` flag of the [install script][install-script]
or via the CLI (with root privileges):
```sh
./AdGuardHome -s uninstall
./AdGuardHome -s install
```
Don't forget to backup your configuration file and other important data before
reinstalling the service.
### Deprecated ### Deprecated
- Node 18 support, Node 20 will be required in future releases. - Node 18 support, Node 20 will be required in future releases.
[#7053]: https://github.com/AdguardTeam/AdGuardHome/issues/7053
[install-script]: https://github.com/AdguardTeam/AdGuardHome/?tab=readme-ov-file#automated-install-linux-and-mac
<!-- <!--
NOTE: Add new changes ABOVE THIS COMMENT. NOTE: Add new changes ABOVE THIS COMMENT.
--> -->

View File

@ -460,8 +460,9 @@ var launchdConfig = `<?xml version='1.0' encoding='UTF-8'?>
// 1. The RestartSec setting is set to a lower value of 10 to make sure we // 1. The RestartSec setting is set to a lower value of 10 to make sure we
// always restart quickly. // always restart quickly.
// //
// 2. The ExecStartPre setting is added to make sure that the log directory is // 2. The StandardOutput and StandardError settings are set to redirect the
// always created to prevent the 209/STDOUT errors. // output to the systemd journal, see
// https://man7.org/linux/man-pages/man5/systemd.exec.5.html#LOGGING_AND_STANDARD_INPUT/OUTPUT.
const systemdScript = `[Unit] const systemdScript = `[Unit]
Description={{.Description}} Description={{.Description}}
ConditionFileIsExecutable={{.Path|cmdEscape}} ConditionFileIsExecutable={{.Path|cmdEscape}}
@ -471,7 +472,6 @@ ConditionFileIsExecutable={{.Path|cmdEscape}}
[Service] [Service]
StartLimitInterval=5 StartLimitInterval=5
StartLimitBurst=10 StartLimitBurst=10
ExecStartPre=/bin/mkdir -p /var/log/
ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}} ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}}
{{if .ChRoot}}RootDirectory={{.ChRoot|cmd}}{{end}} {{if .ChRoot}}RootDirectory={{.ChRoot|cmd}}{{end}}
{{if .WorkingDirectory}}WorkingDirectory={{.WorkingDirectory|cmdEscape}}{{end}} {{if .WorkingDirectory}}WorkingDirectory={{.WorkingDirectory|cmdEscape}}{{end}}
@ -479,8 +479,8 @@ ExecStart={{.Path|cmdEscape}}{{range .Arguments}} {{.|cmd}}{{end}}
{{if .ReloadSignal}}ExecReload=/bin/kill -{{.ReloadSignal}} "$MAINPID"{{end}} {{if .ReloadSignal}}ExecReload=/bin/kill -{{.ReloadSignal}} "$MAINPID"{{end}}
{{if .PIDFile}}PIDFile={{.PIDFile|cmd}}{{end}} {{if .PIDFile}}PIDFile={{.PIDFile|cmd}}{{end}}
{{if and .LogOutput .HasOutputFileSupport -}} {{if and .LogOutput .HasOutputFileSupport -}}
StandardOutput=file:/var/log/{{.Name}}.out StandardOutput=journal
StandardError=file:/var/log/{{.Name}}.err StandardError=journal
{{- end}} {{- end}}
{{if gt .LimitNOFILE -1 }}LimitNOFILE={{.LimitNOFILE}}{{end}} {{if gt .LimitNOFILE -1 }}LimitNOFILE={{.LimitNOFILE}}{{end}}
{{if .Restart}}Restart={{.Restart}}{{end}} {{if .Restart}}Restart={{.Restart}}{{end}}