You are not logged in.
If I call systemctl to shutdown or reboot, it does not honor kodi-x11.service's ExecStop line which results in an unclean exit of kodi and of data loss since kodi writes out some data when it exits:
ExecStop=/usr/bin/killall --user kodi --exact --wait kodi-x11
By contrast, calling systemctl to stop the service works as expected. I suspect that systemd is using some more powerful level of kill to force the application to quit on a shutdown/reboot. Is there a way to modify this behavior to honor the ExecStop= as defined in the service?
EDIT: The addition of a TimeoutStopSec=30 to the [Service] section has no effect.
Last edited by graysky (2020-12-13 13:51:28)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
Shouldn't that have a line in the [Install] section to specify the .target? For example:
[Install]
WantedBy=multi-user.target
Not sure if that Alias line is correct either but I might be wrong.
Freedom for Öcalan!
Offline
Maybe the problem is the X server exiting, and then the kodi program crashing because X is gone?
Offline
@Head - The systemd.service man page suggests WantedBy= believe under [Install]
@Ropid - Something is odd with it for sure. As a test, I changed the ExecStop= to sleep for 20 s and added a 30 sec timeout.
...
ExecStop=/usr/bin/sleep 20s
TimeoutStopSec=30
When I called `systemctl reboot` it did honor the 20 seconds of sleep before rebooting the system. I am uncertain how I can get systemd to behave as I want: wait for the kodi executable to send a clean exit signal before considering the service exited.
Does anyone understand the differences with respect to this aspect of stopping a service as it relates to:
1) systemctl stop kodi-x11 (which behaves as expected)
2) systemctl reboot (which does not behave as expected)
Last edited by graysky (2020-12-13 16:52:14)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
The systemd.service man page suggests WantedBy= believe under [Install]
Sorry but I don't understand what you mean by this
Have you tried adding my suggested line to the [Install] section? The unit will have to be re-enabled to create the new symlink to /etc/systemd/system/multi-user.target.wants/.
Freedom for Öcalan!
Offline
@Head - My bad... misread that. See: https://bbs.archlinux.org/viewtopic.php?pid=1131267
FYI - I did try your suggestion removing the alias line and subing in your line. Reenabled and daemon-reloaded but same problem with systemd killing the service too quickly.
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
I posted to the systemd ML and Andrei was kind enough to reply.
Caused me to search 'systemd wait for user session on shutdown.' Here are two relevant hits:
https://superuser.com/questions/1450650 … own-reboot
https://stackoverflow.com/questions/429 … -on-reboot
It seems that in order to avoid systemd killing my process running as the kodi user without waiting, I need to make certain that it isn't in the user.slice (traceable by running `systemd-cgls`. Removing the PAMName=login seems to achieve this (as well removing systemd-user-sessions.service from After=).
That caused addition issues with a lack of kodi shutdown menu items but I think I can solve that with a polkit rule set. Will do some testing and update the thread.
Last edited by graysky (2020-12-16 14:32:49)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
[Unit]
Description=Fermeture de session
DefaultDependencies=no
Conflicts=shutdown.target
Before=basic.target shutdown.target
[Service]
Type=oneshot
ExecStop=/usr/local/session/bin/session_close.sh
RemainAfterExit=yes
TimeoutStopSec=5m
[Install]
WantedBy=basic.target
Offline