[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Starting systemd user services on boot on a Debian server [SOLVED]



Ansgar Burchardt wrote:
>  Fredrik Jonson <fredrik@jonson.org> writes:
> > What is the recommended way to enable Systemd user services with Debian?
> [...]
>  The documentation for "loginctl enable-linger" says "If enabled for a
>  specific user, a user manager is spawned for the user at boot and kept
>  around after logouts." I guess you didn't restart the system?
>
>  [...]
>
>  A user manager should in either case also be started when logging
>  in. This is handled by logind + libpam-systemd. I assume you might not
>  have the latter installed?

Good guess, that's another culprit identified:

 foouser@host$ sudo apt-get install libpam-systemd
 foouser@host$ sudo shutdown -r now
 [... the system reboots]
 [... I've previously created ~/.config/systemd/user/foo.service]
 foouser@host$ systemctl --user enable foo
 foouser@host$ systemctl --user start foo

Succes!

What a great friday afternoon. Debian is awesome!

>  I don't think you can just start "systemd --user" as it wants to manage
>  cgroups for services it spawns. "/lib/systemd/system/user@.service" has
>  Delegate=yes to allow it to do so.

Right, I was just aimlessly typing commands that I hoped where anywhere close
to relevant to resolving the problem. :)

>  libpam-systemd is also responsible for setting the XDG_RUNTIME_DIR
>  variable.
>
>  libpam-systemd is currently at Priority: optional. I'm wondering if it
>  should be raised to Priority: standard.

Maybe. I gleaned at the package documentation and wasn't totally convinced it
was relevant. There was already a file /etc/pam.d/systemd-user from the systemd
package, so I didn't understand that I also had to install another package that
provided the actual pam module. Would it not make more sense to have the pam
config in the same package that provides the actual pam module?

Still there might have been relevant keywords that I should have picked up on,
the package description does state:

 This package contains the PAM module which registers user sessions in
 the systemd control group hierarchy.

OTOH, in the next paragraph I read the following statement, that definitively
steered me away from installing it:

 If in doubt, do install this package.

When debian developers tells me in their package documentation that I really
should not install their package, I tend to follow their advice. :)

Anyway, it works now.

In summary, to enable systemd user units on boot in Debian, the following steps
are required:

 sudo apt-get install dbus libpam-systemd
 sudo loginctl enable-linger [USER]
 sudo shutdown -r now

Ansgar, I'm greatful, thanks for all your advice!

-- 
Fredrik Jonson


Reply to: