Subject: Re: bug#44669: Shepherd loses track of elogind

From: Marius Bakke <[email-masked]>
Date: Mon, 16 Nov 2020 18:37:20 +0100

Ludovic Courtès <[email-masked]> writes:

> Hi Marius,
>
> Marius Bakke <[email-masked]> skribis:
>
>> On a newly-installed i7 system, Shepherd believes that the "elogind"
>> service is not running.  Yet there is an 'elogind-daemon' process,
>> spawned by PID 1, preventing subsequent "herd start elogind" invocations
>> from succeeding.
>
> Could you show the relevant /var/log/messages bits?  That should show
> when/why elogind stopped.

Indeed.  It was because I had 'sddm-service-type' configured, which
attempted to communicate with "org.freedesktop.login1" over D-Bus, which
in turn autostarted elogind before shepherd had gotten around to it.

Nov 15 21:16:18 localhost dbus-daemon[427]: [system] Activating service name='org.freedesktop.login1' requested by ':1.2' (uid=0 pid=449 comm="/gnu/store/x577n8rs9zcf6ri4aka4pccyj74qxhwh-sddm-0") (using servicehelper)
Nov 15 21:16:18 localhost vmunix: [   46.137561] elogind-daemon[462]: New seat seat0.
Nov 15 21:16:18 localhost vmunix: [   46.138052] elogind-daemon[462]: Watching system buttons on /dev/input/event2 (Power Button)
Nov 15 21:16:18 localhost vmunix: [   46.193372] elogind-daemon[462]: Watching system buttons on /dev/input/event1 (Lid Switch)
Nov 15 21:16:18 localhost vmunix: [   46.193428] elogind-daemon[462]: Watching system buttons on /dev/input/event0 (Sleep Button)
Nov 15 21:16:18 localhost avahi-daemon[444]: Server startup complete. Host name is sirius.local. Local service cookie is 3083842416.
Nov 15 21:16:18 localhost vmunix: [   46.496547] elogind-daemon[462]: Watching system buttons on /dev/input/event3 (AT Translated Set 2 keyboard)
Nov 15 21:16:18 localhost vmunix: [   46.496598] elogind-daemon[462]: Watching system buttons on /dev/input/event4 (ThinkPad Extra Buttons)
Nov 15 21:16:18 localhost dbus-daemon[427]: [system] Successfully activated service 'org.freedesktop.login1'
Nov 15 21:16:18 localhost vmunix: [   46.498084] elogind-daemon[462]: New session c1 of user marius.
Nov 15 21:16:18 localhost shepherd[1]: Service avahi-daemon has been started.
Nov 15 21:16:18 localhost shepherd[1]: Service mcron has been started.
Nov 15 21:16:18 localhost shepherd[1]: Service elogind has been started.
Nov 15 21:16:18 localhost shepherd[1]: Respawning elogind.

> That’s from 1.2.0rc1?

Yes, and also 'master'.  The initial i3 install with 1.2.0rc1 went fine,
it was when I switched to SDDM + autologin (+ sway) that it failed.

Now I no longer use SDDM (or any DM), but I was able to work around it
by adding #:pid-file:

diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm
index 265cf9f35f..6b7d832a44 100644
--- a/gnu/services/desktop.scm
+++ b/gnu/services/desktop.scm
@@ -770,7 +770,8 @@ seats.)"
                    #:environment-variables
                    (list (string-append "ELOGIND_CONF_FILE="
                                         #$(elogind-configuration-file
-                                           config)))))
+                                           config)))
+                   #:pid-file "/run/systemd/elogind.pid"))
          (stop #~(make-kill-destructor)))))
 
 (define elogind-service-type

The race between D-Bus and elogind should probably be handled by having
org.freedesktop.login1 consumers depend on the 'elogind' service instead?