From c1f934e01666370aa9f396dd9b11b983afab12a6 Mon Sep 17 00:00:00 2001 From: Todd Zullinger Date: Tue, 3 Apr 2018 23:35:46 -0400 Subject: [PATCH] daemon: use --log-destination=stderr with systemd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using stderr rather than syslog should be a mild improvement with the systemd journal. The reasons are detailed in the upstream commit 0c591cacba ("daemon: add --log-destination=(stderr|syslog|none)", 2018-02-04)¹: The combination of --inetd with --log-destination=stderr is useful, for instance, when running `git daemon` as an instanced systemd service (with associated socket unit). In this case, log messages sent via syslog are received by the journal daemon, but run the risk of being processed at a time when the `git daemon` process has already exited (especially if the process was very short-lived, e.g. due to client error), so that the journal daemon can no longer read its cgroup and attach the message to the correct systemd unit (see systemd/systemd#2913 [1]). Logging to stderr instead can solve this problem, because systemd can connect stderr directly to the journal daemon, which then already knows which unit is associated with this stream. [1]: https://github.com/systemd/systemd/issues/2913 While here, wrap the git-daemon command line to improve readability. ¹ https://github.com/git/git/commit/0c591cacba --- git.spec | 1 + git@.service.in | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/git.spec b/git.spec index 9f88574..c3e46bc 100644 --- a/git.spec +++ b/git.spec @@ -894,6 +894,7 @@ make test || ./print-failed-test-output %changelog * Mon Apr 09 2018 Todd Zullinger +- daemon: use --log-destination=stderr with systemd - daemon: fix condition for redirecting stderr - git-svn: avoid uninitialized value warning diff --git a/git@.service.in b/git@.service.in index bb93b78..7abcfeb 100644 --- a/git@.service.in +++ b/git@.service.in @@ -4,5 +4,7 @@ Documentation=man:git-daemon(1) [Service] User=nobody -ExecStart=-@GITEXECDIR@/git-daemon --base-path=@BASE_PATH@ --export-all --user-path=public_git --syslog --inetd --verbose +ExecStart=-@GITEXECDIR@/git-daemon --base-path=@BASE_PATH@ --export-all \ + --user-path=public_git --inetd --log-destination=stderr --verbose StandardInput=socket +StandardError=journal