[systemd-devel] require a system service unit to start a user service as a dependency

Lennart Poettering lennart at poettering.net
Mon Jan 4 15:27:07 UTC 2021


On Mi, 23.12.20 21:47, John (graysky at archlinux.us) wrote:

> I need to have the following start
> /usr/lib/systemd/user/pulseaudio.service so it can make use of
> pulseaudio.  Using a After= or Wants= does not work.  What is the
> correct way to have a system service like this run a user service
> unit?
>
> % cat /usr/lib/systemd/system/kodi.service
> [Unit]
> Description=Kodi standalone (GBM)
> After=remote-fs.target network-online.target nss-lookup.target
> sound.target bluetooth.target polkit.service upower.service
> mysqld.service
> Wants=network-online.target polkit.service upower.service
> Conflicts=getty at tty1.service
>
> [Service]
> User=kodi
> Group=kodi
> EnvironmentFile=-/etc/conf.d/kodi-standalone
> TTYPath=/dev/tty1
> Environment=WINDOWING=gbm
> ExecStart=/usr/bin/kodi-standalone
> ExecStop=/usr/bin/killall --user kodi --exact --wait kodi-gbm
> Restart=on-abort
> StandardInput=tty
> StandardOutput=journal
>
> [Install]
> Alias=display-manager.service

This is not a supported setup. System services should not be clients
to per-user services. The opposite is OK, but you are reversing your
stack here...

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list