1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-26 08:55:40 +03:00
systemd/units/capsule@.service.in
Mike Yuan a375e14519 units/{user,capsule}@.service: issue daemon-reexec when notify-reloading
Closes #28367 (but not really in the exact form, see below)

We have the problem of restarting all user manager instances
after upgrade. Current approaches involve systemctl kill
with SIGRTMIN+25, which is async and feels rather ugly [1][2];
or systemctl --machine=user@ --user, which requires entering
each user session. Neither is particularly elegant.
Instead, let's just signal daemon-reexec when user@.service
is reloaded from system manager. Our long goal of dropping
daemon-reload in favor of reexec (see TODO) is unlikely to happen
due to user dbus restrictions, but here the synchronization
is done via READY=1.

[1] https://gitlab.archlinux.org/archlinux/packaging/packages/systemd/-/blob/main/systemd.install?ref_type=heads#L37
[2] https://salsa.debian.org/systemd-team/systemd/-/blob/debian/master/debian/systemd.postinst#L24

#28367 would not really work for us now I come to think about it,
because all processes will be reparented to pid1 as soon as
original user manager process exits. This alternative approach
seems good enough for our use case.
2024-10-11 10:36:08 +02:00

38 lines
1.1 KiB
SYSTEMD

# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Capsule Service Manager for %i
Documentation=man:capsule@.service(5)
After=dbus.service systemd-oomd.service
[Service]
User=c-%i
DynamicUser=yes
Type=notify-reload
ExecStart={{LIBEXECDIR}}/systemd --user --unit=capsule@%i.target
Environment=HOME=/var/lib/capsules/%i
Environment=XDG_RUNTIME_DIR=/run/capsules/%i
StateDirectory=capsules/%i
RuntimeDirectory=capsules/%i
LogExtraFields=CAPSULE=%i
Slice=capsule.slice
# Reexecute the manager on service reload, instead of reloading.
# This provides a synchronous method for restarting all user manager
# instances after upgrade.
ReloadSignal=RTMIN+25
KillMode=mixed
Delegate=pids memory cpu
DelegateSubgroup=init.scope
TasksMax=infinity
TimeoutStopSec={{ DEFAULT_USER_TIMEOUT_SEC*4//3 }}s
KeyringMode=inherit
OOMScoreAdjust=100
MemoryPressureWatch=skip