daemon: add systemd support
Subsystems (2)
RFC PATCH v4 1/1 daemon: add systemd support
systemd supports git-daemon's existing --inetd mode as well.
Signed-off-by Shawn Landden <[email protected]>
--- Documentation/git-daemon.txt | 41 +++++++++++++++++++++++++++++++++++----- Makefile | 14 ++++++++++++-- daemon.c | 45 ++++++++++++++++++++++++++++++++++++++------ 3 files changed, 87 insertions(+), 13 deletions(-)
Respond to review in http://article.gmane.org/gmane.comp.version-control.git/266650
I did not indent the example documents as that was for inetd, and that would break copy/paste.
These are all documentation changes, no functional differences. (Well, the example gained StandardError=null to match --inetd)
Documentation/git-daemon.txt +36 -5
@@ -18,7 +18,7 @@ SYNOPSIS [--allow-override=<service>] [--forbid-override=<service>] [--access-hook=<path>] [--[no-]informative-errors] [--inetd | - [--listen=<host_or_ipaddr>] [--port=<n>] + [--listen=<host_or_ipaddr>] [--port=<n>] [--systemd] [--user=<user> [--group=<group>]]] [<directory>...]
@@ -81,8 +81,8 @@ OPTIONS --inetd:: Have the server run as an inetd service. Implies --syslog. - Incompatible with --detach, --port, --listen, --user and --group - options. + Incompatible with --systemd, --detach, --port, --listen, --user and + --group options. --listen=<host_or_ipaddr>:: Listen on a specific IP address or hostname. IP addresses can
@@ -146,8 +146,8 @@ OPTIONS the option are given to `getpwnam(3)` and `getgrnam(3)` and numeric IDs are not supported. + -Giving these options is an error when used with `--inetd`; use -the facility of inet daemon to achieve the same before spawning +Giving these options is an error when used with `--inetd` or `--systemd`; use +the facility of systemd or the inet daemon to achieve the same before spawning 'git daemon' if needed. + Like many programs that switch user id, the daemon does not reset
@@ -180,6 +180,14 @@ Git configuration files in that directory are readable by `<user>`. errors are not enabled, all errors report "access denied" to the client. The default is --no-informative-errors. +--systemd:: + For running git-daemon under systemd(1) which will pass + an open connection. This is similar to --inetd, except + that more than one address/port can be listened to at once + both through systemd and through --listen, and git-daemon doesn't get + invoked for every connection. For more details see systemd.socket(5). + Incompatible with --inetd, --detach, --user and --group options. + --access-hook=<path>:: Every time a client connects, first run an external command specified by the <path> with service name (e.g. "upload-pack"),
@@ -304,7 +312,30 @@ selectively enable/disable services per repository:: uploadpack = false uploadarch = true ---------------------------------------------------------------- ++ + +systemd configuration example:: ++ +---------------------------------------------------------------- +# /etc/systemd/system/git-daemon.socket +[Unit] +Description=Git Daemon socket +[Socket] +ListenStream=9418 + +[Install] +WantedBy=sockets.target + +# /etc/systemd/system/git-daemon.service +[Unit] +Description=Git Daemon + +[Service] +ExecStart=/usr/lib/git-core/git-daemon --systemd --reuseaddr --base-path=/var/lib /var/lib/git +User=git-daemon +StandardError=null +---------------------------------------------------------------- ENVIRONMENT -----------
Makefile +12 -2
@@ -42,6 +42,9 @@ all:: # Define NO_EXPAT if you do not have expat installed. git-http-push is # not built, and you cannot push using http:// and https:// transports (dumb). # +# Define NO_SYSTEMD to prevent systemd socket activation support from being +# built into git-daemon. +# # Define EXPATDIR=/foo/bar if your expat header and library files are in # /foo/bar/include and /foo/bar/lib directories. #
@@ -995,6 +998,13 @@ ifeq ($(uname_S),Darwin) PTHREAD_LIBS = endif +ifndef NO_SYSTEMD + ifeq ($(shell echo "\#include <systemd/sd-daemon.h>" | $(CC) -E - -o /dev/null && echo y),y) + BASIC_CFLAGS += -DHAVE_SYSTEMD + EXTLIBS += -lsystemd + endif +endif + ifndef CC_LD_DYNPATH ifdef NO_R_TO_GCC_LINKER # Some gcc does not accept and pass -R to the linker to specify
@@ -1403,8 +1413,8 @@ ifdef NATIVE_CRLF endif ifdef USE_NED_ALLOCATOR - COMPAT_CFLAGS += -Icompat/nedmalloc - COMPAT_OBJS += compat/nedmalloc/nedmalloc.o + COMPAT_CFLAGS += -Icompat/nedmalloc + COMPAT_OBJS += compat/nedmalloc/nedmalloc.o endif ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
daemon.c +39 -6
85 lines not on this page · raw message
Signature · 1 line
2.2.1.209.g41e5f3a