Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion book/04-git-server/sections/git-daemon.asc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down