progit2 icon indicating copy to clipboard operation
progit2 copied to clipboard

New explanation for git daemon/systemd doesn't quite cover it.

Open rpjday opened this issue 8 years ago • 1 comments

I'll put something together in the next few days but, in some cases, it's unnecessary to manually create a systemd service file for git-daemon as some distros already come with a package to handle that. For example, Fedora has a "git-daemon" package (list of files here):

$ rpm -ql git-daemon
/usr/lib/systemd/system/git.socket
/usr/lib/systemd/system/[email protected]
/usr/libexec/git-core/git-daemon
/usr/share/doc/git/git-daemon.html
/usr/share/doc/git/git-daemon.txt
/usr/share/man/man1/git-daemon.1.gz
/var/lib/git
$

As you can see, that package supplies both a socket and a service file, as well as documentation. In addition, just to make things more challenging, the service file is a systemd template unit file, explained here. Long story short -- template unit files are meant to support services for which daemons are started on demand, so all one needs to do in this case is install the git-daemon package, then start and enable the socket only:

$ sudo systemctl enable git.socket
$ sudo systemctl start git.socket
$ systemctl status git.socket
● git.socket - Git Activation Socket
   Loaded: loaded (/usr/lib/systemd/system/git.socket; enabled; vendor preset: disabled)
   Active: active (listening) since Tue 2017-10-10 15:27:17 EDT; 12h ago
   Listen: [::]:9418 (Stream)
 Accepted: 0; Connected: 0

Oct 10 15:27:17 localhost.localdomain systemd[1]: Listening on Git Activation Socket.
$

At that point, any network requests coming to that socket spawn the Git daemon on demand -- systemd template unit files are kind of the way to go these days.

I'll figure out how to condense this and cram it into the section on systemd since it's pretty important to describe.

P.S. template unit files are identified by the "@" in their file name:

[email protected]     [email protected]              [email protected]
[email protected]      [email protected]  [email protected]
[email protected]             [email protected]    [email protected]
[email protected]       [email protected]                [email protected]
[email protected]      [email protected]       [email protected]
[email protected]  [email protected]       [email protected]
[email protected]    [email protected]              [email protected]
[email protected]                [email protected]                [email protected]
[email protected]              [email protected]         [email protected]
[email protected]                [email protected]          [email protected]
[email protected]        [email protected]

rpjday avatar Oct 11 '17 08:10 rpjday

@rpjday Is this still relevant today? It pass 5 years since 2017 and a lot can change in such time.

KZiemian avatar Aug 27 '22 15:08 KZiemian