Como posso fazer com que o serviço systemd pare e termine a parada antes de “Stopping Session”… “of user”…?

0

Eu vejo algo assim:

[  181.919605] preshutdown[3874]: Starting /home/ctor/bin/preshutdown
[  181.920611] crond[3284]: (CRON) INFO (Shutting down)
[  181.931087] systemd[1]: Stopping Session 2 of user ctor.
...
[  211.953070] systemd[1]: session-2.scope: Stopping timed out. Killing.
[  211.953183] systemd[1]: session-2.scope: Killing process 3584 (qubes-guid) with signal SIGKILL.
[  211.953372] systemd[1]: [email protected]: State 'stop-sigterm' timed out. Killing.
[  211.953742] systemd[1]: [email protected]: Killing process 3382 (systemd) with signal SIGKILL.
[  211.954105] systemd[1]: [email protected]: Killing process 3874 (preshutdown) with signal SIGKILL.
[  211.954153] systemd[1]: [email protected]: Killing process 4923 (sleep) with signal SIGKILL.
[  211.956105] systemd[1]: Stopped User Manager for UID 1000.
[  211.956164] systemd[1]: [email protected]: Unit entered failed state.
[  211.956186] systemd[1]: [email protected]: Failed with result 'timeout'.
[  211.956386] systemd[1]: Stopped Session 2 of user ctor.
[  211.956515] systemd[1]: session-2.scope: Unit entered failed state.
[  211.956877] systemd[1]: dev-disk-by\x2did-lvm\x2dpv\x2duuid\x2dpxC3ch\x2d0MF0\x2dOzJs\x2dJogd\x2d9rOz\x2dJkSt\x2dCf8G7m.device: Job dev-disk-by\x2did-lvm\x2dpv\x2duuid\x2dpxC3ch\x2d0MF0\x2dOzJs\x2dJogd\x2d9rOz\x2dJkSt\x2dCf8G7m.device/stop timed out.
[  211.956951] systemd[1]: Timed out stopping /dev/disk/by-id/lvm-pv-uuid-pxC3ch-0MF0-OzJs-Jogd-9rOz-JkSt-Cf8G7m.
[  211.957107] systemd[1]: dev-disk-by\x2did-lvm\x2dpv\x2duuid\x2dpxC3ch\x2d0MF0\x2dOzJs\x2dJogd\x2d9rOz\x2dJkSt\x2dCf8G7m.device: Job dev-disk-by\x2did-lvm\x2dpv\x2duuid\x2dpxC3ch\x2d0MF0\x2dOzJs\x2dJogd\x2d9rOz\x2dJkSt\x2dCf8G7m.device/stop failed with result 'timeout'.
[  211.957280] systemd[1]: dev-disk-by\x2did-dm\x2dname\x2dluks\x2d9ed952b5\x2d2aa8\x2d4564\x2db700\x2dfb23f5c9e94b.device: Job dev-disk-by\x2did-dm\x2dname\x2dluks\x2d9ed952b5\x2d2aa8\x2d4564\x2db700\x2dfb23f5c9e94b.device/stop timed out.
[  211.957335] systemd[1]: Timed out stopping /dev/disk/by-id/dm-name-luks-9ed952b5-2aa8-4564-b700-fb23f5c9e94b.
[  211.957398] systemd[1]: dev-disk-by\x2did-dm\x2dname\x2dluks\x2d9ed952b5\x2d2aa8\x2d4564\x2db700\x2dfb23f5c9e94b.device: Job dev-disk-by\x2did-dm\x2dname\x2dluks\x2d9ed952b5\x2d2aa8\x2d4564\x2db700\x2dfb23f5c9e94b.device/stop failed with result 'timeout'.
[  211.957611] systemd[1]: dev-block-253:0.device: Job dev-block-253:0.device/stop timed out.
[  211.957647] systemd[1]: Timed out stopping LVM PV pxC3ch-0MF0-OzJs-Jogd-9rOz-JkSt-Cf8G7m on /dev/dm-0.
[  211.957715] systemd[1]: dev-block-253:0.device: Job dev-block-253:0.device/stop failed with result 'timeout'.
[  211.957770] systemd[1]: dev-dm\x2d0.device: Job dev-dm\x2d0.device/stop timed out.
[  211.957798] systemd[1]: Timed out stopping /dev/dm-0.
[  211.957847] systemd[1]: dev-dm\x2d0.device: Job dev-dm\x2d0.device/stop failed with result 'timeout'.
[  211.957901] systemd[1]: dev-disk-by\x2did-dm\x2duuid\x2dCRYPT\x2dLUKS1\x2d9ed952b52aa84564b700fb23f5c9e94b\x2dluks\x2d9ed952b5\x2d2aa8\x2d4564\x2db700\x2dfb23f5c9e94b.device: Job dev-disk-by\x2did-dm\x2duuid\x2dCRYPT\x2dLUKS1\x2d9ed952b52aa84564b700fb23f5c9e94b\x2dluks\x2d9ed952b5\x2d2aa8\x2d4564\x2db700\x2dfb23f5c9e94b.device/stop timed out.
[  211.957972] systemd[1]: Timed out stopping /dev/disk/by-id/dm-uuid-CRYPT-LUKS1-9ed952b52aa84564b700fb23f5c9e94b-luks-9ed952b5-2aa8-4564-b700-fb23f5c9e94b.
[  211.958047] systemd[1]: dev-disk-by\x2did-dm\x2duuid\x2dCRYPT\x2dLUKS1\x2d9ed952b52aa84564b700fb23f5c9e94b\x2dluks\x2d9ed952b5\x2d2aa8\x2d4564\x2db700\x2dfb23f5c9e94b.device: Job dev-disk-by\x2did-dm\x2duuid\x2dCRYPT\x2dLUKS1\x2d9ed952b52aa84564b700fb23f5c9e94b\x2dluks\x2d9ed952b5\x2d2aa8\x2d4564\x2db700\x2dfb23f5c9e94b.device/stop failed with result 'timeout'.
[  211.958075] systemd[1]: sys-devices-virtual-block-dm\x2d0.device: Job sys-devices-virtual-block-dm\x2d0.device/stop timed out.
[  211.958174] systemd[1]: Timed out stopping /sys/devices/virtual/block/dm-0.
[  211.958222] systemd[1]: sys-devices-virtual-block-dm\x2d0.device: Job sys-devices-virtual-block-dm\x2d0.device/stop failed with result 'timeout'.
[  211.958774] systemd[1]: Removed slice User Slice of ctor.
[  211.958911] systemd[1]: Stopping Login Service...
[  211.960223] systemd[1]: Stopping Permit User Sessions...
[  211.964389] systemd[1]: Stopped Permit User Sessions.
[  211.964558] systemd[1]: Stopped Start Qubes VM sys-net.
[  211.964618] systemd[1]: Stopped Start Qubes VM sys-firewall.
[  211.966532] systemd[1]: Removed slice system-qubes\x2dvm.slice.
[  211.970050] systemd[1]: Stopping Qubes memory information reporter...
[  211.975886] systemd[1]: Stopped Qubes memory information reporter.
[  211.982513] systemd[1]: Stopping Qubes Dom0 startup setup...

O preshutdown acima é de um --user .service que não é mencionado nesse log como Stopping (não sei por que).

Mas, independentemente de ser um --user ou --system service, como posso dizer ao systemd para parar meu serviço e terminar de interrompê-lo ANTES de tentar Stopping Session X of user Y ?

Se você souber como resolver essa questão, provavelmente poderá resolver (ou me ajudar a resolver) isso um também, e recolher essa pequena recompensa.

Se for relevante, este é o meu --user service ( /usr/lib/systemd/user/mowron.service ) que gerou o log acima:

[Unit]
Description=Mowron
#Wants=
RequiresMountsFor=/home/ /dev/dm-0 /dev/disk/by-id/dm-uuid-CRYPT-LUKS1-9ed952b52aa84564b700fb23f5c9e94b-luks-9ed952b5-2aa8-4564-b700-fb23f5c9e94b /dev/disk/by-id/lvm-pv-uuid-pxC3ch-0MF0-OzJs-Jogd-9rOz-JkSt-Cf8G7m /dev/disk/by-id/dm-name-luks-9ed952b5-2aa8-4564-b700-fb23f5c9e94b /sys/devices/virtual/block/dm-0
After=qubes-db-dom0.service libvirtd.service xenconsoled.service qubesd.service qubes-qmemman.service systemd-udev-settle.service remote-fs.target remote-fs-pre.target systemd-user-sessions.service
Conflicts=shutdown.target reboot.target halt.target
#BindsTo=systemd-udev-settle.service systemd-user-sessions.service
#PartOf=systemd-user-sessions.service
#Wants=systemd-user-sessions.service
#Requires=systemd-user-sessions.service
#Failed to start mowron.service: Unit systemd-user-sessions.service not found.
#i mean, it's only here: /usr/lib/systemd/system/systemd-user-sessions.service



[Service]
Type=oneshow
RemainAfterExit=yes
ExecStart=/bin/true
ExecStop=/home/ctor/bin/preshutdown

[Install]
WantedBy=default.target

Versão systemd do Fedora 25 (não consigo atualizar):

[ctor@dom0 ~]$ systemctl --version
systemd 231
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN
    
por Marcus Linsner 10.09.2018 / 09:42

0 respostas