diff --git a/book/04-git-server/sections/git-daemon.asc b/book/04-git-server/sections/git-daemon.asc index c5332a494..64f7a0d0d 100644 --- a/book/04-git-server/sections/git-daemon.asc +++ b/book/04-git-server/sections/git-daemon.asc @@ -20,7 +20,40 @@ $ git daemon --reuseaddr --base-path=/srv/git/ /srv/git/ If you're running a firewall, you'll also need to punch a hole in it at port 9418 on the box you're setting this up on. You can daemonize this process a number of ways, depending on the operating system you're running. -On an Ubuntu machine, you can use an Upstart script. + +Since `systemd` is the most common init system among modern Linux distributions, you can use it for that purpose. +Simply place a file in `/etc/systemd/system/git-daemon.service` with these contents: + +[source,console] +---- +[Unit] +Description=Start Git Daemon + +[Service] +ExecStart=git daemon --reuseaddr --base-path=/srv/git/ /srv/git/ + +Restart=always +RestartSec=500ms + +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=git-daemon + +User=git +Group=git + +[Install] +WantedBy=multi-user.target +---- + +You might have noticed that Git daemon is started here with `git` as both group and user. + +Modify it to fit your needs and make sure provided user exists on the system. + +Finally, you'll run `systemctl enable git-daemon` to automatically start the service on boot, and the usual service commands like `service start` and `service stop` are instantly available. + +Until LTS 14.04, Ubuntu used upstart service unit configuration. +Therefore, on Ubuntu <= 14.04 you can use an Upstart script. So, in the following file [source,console]