From ba90bec1448c694bff9a1703a75939a1c640d8d2 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Fri, 20 Dec 2013 16:16:41 +0000 Subject: [PATCH] Add support for bus-activation via systemd service unit On systemd systems it is preferred to use systemd to launch services in order to properly track processes and allocate system resources. When dbus launches binary daemons internally they will stay in the dbus cgroup and thus proper resource allocation and process tracking is not possible. https://bugs.freedesktop.org/show_bug.cgi?id=72925 --- configure.ac | 11 +++++++++++ data/Makefile.am | 12 ++++++++++++ data/geoclue.service.in | 8 ++++++++ data/org.freedesktop.GeoClue2.service.in | 1 + 4 files changed, 32 insertions(+) create mode 100644 data/geoclue.service.in diff --git a/configure.ac b/configure.ac index fe85832..d1cf9a0 100644 --- a/configure.ac +++ b/configure.ac @@ -167,6 +167,16 @@ else ifelse([$1],,[:],[$1]) fi +# systemd +AC_ARG_WITH([systemdsystemunitdir], + AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]), + [], + [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)]) +if test "x$with_systemdsystemunitdir" != "xno"; then + AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir]) +fi +AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$systemdsystemunitdir"]) + AC_CONFIG_FILES([ Makefile src/Makefile @@ -191,4 +201,5 @@ AC_MSG_NOTICE([ prefix: ${prefix} c compiler: ${CC} ${CFLAGS} + systemdsystemunitdir: ${systemdsystemunitdir} ]) diff --git a/data/Makefile.am b/data/Makefile.am index 8c77c7a..4f40e0b 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -11,8 +11,20 @@ dbusservicedir = $(DBUS_SYS_DIR) dbusservice_DATA = org.freedesktop.GeoClue2.conf \ org.freedesktop.GeoClue2.Agent.conf +systemdservice_in_files = geoclue.service.in + +if HAVE_SYSTEMD +systemdservicedir = $(systemdsystemunitdir) +systemdservice_DATA = $(systemdservice_in_files:.service.in=.service) + +$(systemdservice_DATA): $(systemdservice_in_files) Makefile + @sed -e "s|\@libexecdir\@|$(libexecdir)|" $< | \ + sed -e "s|\@dbus_srv_user\@|$(dbus_srv_user)|" > $@ +endif + DISTCLEANFILES = $(service_DATA) EXTRA_DIST = $(service_in_files) \ + $(systemdservice_in_files) \ $(dbusservice_DATA) -include $(top_srcdir)/git.mk diff --git a/data/geoclue.service.in b/data/geoclue.service.in new file mode 100644 index 0000000..812cb67 --- /dev/null +++ b/data/geoclue.service.in @@ -0,0 +1,8 @@ +[Unit] +Description=Location Lookup Service + +[Service] +Type=dbus +BusName=org.freedesktop.GeoClue2 +User=@dbus_srv_user@ +ExecStart=@libexecdir@/geoclue -t 5 diff --git a/data/org.freedesktop.GeoClue2.service.in b/data/org.freedesktop.GeoClue2.service.in index 51cbdb2..ef16223 100644 --- a/data/org.freedesktop.GeoClue2.service.in +++ b/data/org.freedesktop.GeoClue2.service.in @@ -2,3 +2,4 @@ Name=org.freedesktop.GeoClue2 Exec=@libexecdir@/geoclue -t 5 User=@dbus_srv_user@ +SystemdService=geoclue.service -- 1.8.4.5