git/git@.service.in
Todd Zullinger c1f934e016 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 
    [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
2018-04-11 23:19:00 -04:00

11 lines
298 B
SYSTEMD

[Unit]
Description=Git Repositories Server Daemon
Documentation=man:git-daemon(1)
[Service]
User=nobody
ExecStart=-@GITEXECDIR@/git-daemon --base-path=@BASE_PATH@ --export-all \
--user-path=public_git --inetd --log-destination=stderr --verbose
StandardInput=socket
StandardError=journal