daemon: use --log-destination=stderr with systemd

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
This commit is contained in:
Todd Zullinger 2018-04-03 23:35:46 -04:00
parent f25fef61e0
commit c1f934e016
2 changed files with 4 additions and 1 deletions

View File

@ -894,6 +894,7 @@ make test || ./print-failed-test-output
%changelog
* Mon Apr 09 2018 Todd Zullinger <tmz@pobox.com>
- daemon: use --log-destination=stderr with systemd
- daemon: fix condition for redirecting stderr
- git-svn: avoid uninitialized value warning

View File

@ -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