[dconf/wip/smcv/systemd-unit: 17/17] service: Add a systemd unit for D-Bus activation
- From: Daniel Playfair Cal <danielplayfaircal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf/wip/smcv/systemd-unit: 17/17] service: Add a systemd unit for D-Bus activation
- Date: Sun, 7 Feb 2021 23:01:30 +0000 (UTC)
commit 2781a8684855e4120c9948d8b40880bafafe1b12
Author: Simon McVittie <smcv collabora com>
Date: Fri Dec 4 11:11:04 2020 +0000
service: Add a systemd unit for D-Bus activation
On systems using systemd --user and
dbus-daemon --session --systemd-activation, this means that dconf
is correctly placed in its own cgroup, instead of being part of
dbus.service's cgroup. This allows it to be controlled by
systemctl --user, have resource limits set and so on.
On other systems (in particular those where systemd is not used at all),
the SystemdService field is ignored and dbus-daemon will continue to
start dconf-service as its own child process ("traditional activation"),
making this change harmless to apply.
Resolves: https://gitlab.gnome.org/GNOME/dconf/-/issues/24
Signed-off-by: Simon McVittie <smcv collabora com>
meson.build | 14 ++++++++++++++
meson_options.txt | 1 +
service/ca.desrt.dconf.service.in | 1 +
service/dconf.service.in | 8 ++++++++
service/meson.build | 9 +++++++++
5 files changed, 33 insertions(+)
---
diff --git a/meson.build b/meson.build
index 41fe1a9..6e88015 100644
--- a/meson.build
+++ b/meson.build
@@ -48,6 +48,20 @@ glib_dep = dependency('glib-2.0', version: '>= 2.44.0')
gio_module_dir = gio_dep.get_pkgconfig_variable('giomoduledir', define_variable: ['libdir', dconf_libdir])
dbus_session_service_dir = dependency('dbus-1').get_pkgconfig_variable('session_bus_services_dir',
define_variable: ['datadir', dconf_datadir])
+systemd_userunitdir = get_option('systemduserunitdir')
+
+if systemd_userunitdir == ''
+ systemd_dep = dependency('systemd', required: false)
+
+ if systemd_dep.found()
+ systemd_userunitdir = systemd_dep.get_pkgconfig_variable('systemduserunitdir')
+ else
+ # Fall back to the upstream default.
+ # Note that this is always 'lib', even if libdir is something else
+ systemd_userunitdir = join_paths(dconf_prefix, 'lib', 'systemd', 'user')
+ endif
+endif
+
enable_bash_completion = get_option('bash_completion')
if enable_bash_completion
bash_completion_dep = dependency('bash-completion')
diff --git a/meson_options.txt b/meson_options.txt
index a2794ce..1b85d5d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -2,3 +2,4 @@ option('bash_completion', type: 'boolean', value: true, description: 'install ba
option('man', type: 'boolean', value: true, description: 'generate man pages')
option('gtk_doc', type: 'boolean', value: false, description: 'use gtk-doc to build documentation')
option('vapi', type: 'boolean', value: true, description: 'install dconf client vapi')
+option('systemduserunitdir', type: 'string', value: '', description: 'override systemd user unit directory')
diff --git a/service/ca.desrt.dconf.service.in b/service/ca.desrt.dconf.service.in
index 369948a..be0b911 100644
--- a/service/ca.desrt.dconf.service.in
+++ b/service/ca.desrt.dconf.service.in
@@ -1,3 +1,4 @@
[D-BUS Service]
Name=ca.desrt.dconf
Exec=@libexecdir@/dconf-service
+SystemdService=dconf.service
diff --git a/service/dconf.service.in b/service/dconf.service.in
new file mode 100644
index 0000000..e3c7cef
--- /dev/null
+++ b/service/dconf.service.in
@@ -0,0 +1,8 @@
+[Unit]
+Description=User preferences database
+Documentation=man:dconf-service(1)
+
+[Service]
+ExecStart=@libexecdir@/dconf-service
+Type=dbus
+BusName=ca.desrt.dconf
diff --git a/service/meson.build b/service/meson.build
index 51e3090..a2045e5 100644
--- a/service/meson.build
+++ b/service/meson.build
@@ -10,6 +10,15 @@ configure_file(
install_dir: dbus_session_service_dir,
)
+systemd_service = 'dconf.service'
+
+configure_file(
+ input: systemd_service + '.in',
+ output: systemd_service,
+ configuration: service_conf,
+ install_dir: systemd_userunitdir,
+)
+
lib_sources = [
'dconf-blame.c',
'dconf-keyfile-writer.c',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]