Skip to content

daemon: Move systemd services to session slice and add PartOf=

Henri Chain requested to merge unusual-thoughts/gvfs:session-slice into master

This puts all gvfs systemd services (which are all dbus-activated through SystemdService=) inside of the session slice that was introduced in v249 (https://github.com/systemd/systemd/pull/16603) and described in https://systemd.io/DESKTOP_ENVIRONMENTS/ and systemd.special(7)

This allows sysadmins or OS integrators to assign higher-priority systemd.resource-control(5) on session.slice and have it propagate down to important session services such as gvfs, so that the gvfs daemons receive sufficient priority for resource allocations to keep the session running smoothly under load.

Note that it still works on older systemd (the slice, which is just a cgroup inner directory, is created on demand)

The PartOf directive sets up a one-way dependency between graphical-session.target and our services, so that when graphical-session.target is stopped or restarted, our services also get stopped or restarted.

This ensures that gvfs daemons that were started in the context of a GUI login session (through dbus activation) do not continue to run after the user has logged out.

From systemd.special(7):

session.slice
    All essential services and applications required for the session should use this slice. These are services that
    either cannot be restarted easily or where latency issues may affect the interactivity of the system and
    applications. This includes the display server, screen readers and other services such as DBus or XDG portals.
    Such services should be configured to be part of this slice by adding Slice=session.slice to their unit files.

graphical-session.target
    This target is active whenever any graphical session is running. It is used to stop user services which only 
    apply to a graphical (X, Wayland, etc.) session when the session is terminated. Such services should have
    "PartOf=graphical-session.target" in their [Unit] section. A target for a particular session (e. g. 
    gnome-session.target) starts and stops "graphical-session.target" with "BindsTo=graphical-session.target".
Edited by Henri Chain

Merge request reports