Subject: bug#63982: Service hangs in 'starting' with Shepherd 0.10 (was: Shepherd can crash when a user service fails to start)

From: Maxim Cournoyer <[email-masked]>
Date: Sun, 18 Jun 2023 21:42:57 -0400

Hi Ludo,

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

> Hi,
>
> Maxim Cournoyer <[email-masked]> skribis:
>
>>> I believe this is fixed by Shepherd commit
>>> 24c964021ebd3d63ce6e22808dd09dbe16116a6c, which introduces an additional
>>> change: loading the config file asynchronously.
>>
>> Nitpick: I'd use a git message tag for 'Reported-by', as can be inserted
>> in the commit buffer in Magit with C-c C-p.  They should be placed at
>> the bottom of the git message to be considered by tools parsing them.
>
> Neat, I didn’t know about it, I’ll do that now (I think I started using
> the “Reported by” convention before Git came into existence…).
>
>>> If you wish to test it, you can use the ‘shepherd’ channel.
>>
>> I've done so by placing in my ~/.config/guix/channels.scm file:
>>
>>        (channel
>>         (name 'shepherd)
>>         (url "https://git.savannah.gnu.org/git/shepherd.git")
>>         (introduction
>>          (make-channel-introduction
>>           "788a6d6f1d5c170db68aa4bbfb77024fdc468ed3"  ;2022-05-21
>>           (openpgp-fingerprint
>>            "3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5"))))
>>
>>
>> It'd be nice to have this in the Shepherd doc for easy copy & paste.
>
> I’ll add that to ‘README’.

Neat, thank you.

>>> Let me know how it goes!
>>
>> I've edited my ~/.xsession file to use
>> /gnu/store/ahzl8vxxcd5bqlljwgn8wkp4884sr72l-shepherd-0.10.99-tarball,
>> and I'm now seeing this:
>>
>> $ herd status
>> Démarrés :
>>  + root
>> Starting:
>>  ^ emacs
>> Arrêtés :
>>  - gpg-agent
>>  - ibus-daemon
>>  - jackd
>>  - workrave
>
> Uh, so it remains in “starting” state?

Yes!  Which is surprising, because it's actually running fine, and
Shepherd 0.9.3 didn't have this issue (perhaps because it only knew of a
started/stopped service).

The other surprising thing is that because it thinks that Emacs hasn't
finished starting, it doesn't even attempt to try starting the other
services; they remain stopped although they should work.

[...]

> Looks like it.  Could you share ~/.local/var/log/shepherd.log?

I have something a bit more detailed, with various versions (the logs
are under ~/.local/state/shepherd/shepherd.log by default).  If you need
to, you should be able to reproduce on your end using the attached
~/.config/shepherd/{init.scm,services.scm} files (and ensuring the
service commands are on your PATH):

--8<---------------cut here---------------start------------->8---
Using /gnu/store/dblbnj1yra4yrrfjbnzsa0ldcl3170ap-shepherd-0.9.1/bin/shepherd

$ herd status
Started:
 + Emacs
 + Gpg-agent
 + ibus-daemon
 + jackd
 + root
 + workrave

Using /gnu/store/cdc1gzbp3q15kdiwn2i5j3437jwx61ac-shepherd-0.9.2/bin/shepherd

$ herd status
Started:
 + emacs
 + gpg-agent
 + ibus-daemon
 + jackd
 + root
 + workrave

Using /gnu/store/a9jdd8kgckwlq97yw3pjqs6sy4lqgrfq-shepherd-0.9.3/bin/shepherd

$ herd status
Started:
 + emacs
 + gpg-agent
 + ibus-daemon
 + jackd
 + root
 + workrave

~/.local/state/shepherd/shepherd.log:

2023-06-18 21:04:47 Service root démarré.
2023-06-18 21:04:57 Service emacs démarré.
2023-06-18 21:04:57 Service jackd démarré.
2023-06-18 21:04:57 Service gpg-agent démarré.
2023-06-18 21:04:57 Service ibus-daemon démarré.
2023-06-18 21:04:57 Service workrave démarré.

Using /gnu/store/ahzl8vxxcd5bqlljwgn8wkp4884sr72l-shepherd-0.10.99-tarball/bin/shepherd

$ herd status
Started:
 + root
Starting:
 ^ emacs
Stopped:
 - gpg-agent
 - ibus-daemon
 - jackd
 - workrave

~/.local/state/shepherd/shepherd.log:

2023-06-18 21:06:12 Starting service root...
2023-06-18 21:06:12 Service root started.
2023-06-18 21:06:12 Service root running with value #t.
2023-06-18 21:06:12 Service root démarré.
2023-06-18 21:06:12 Starting service emacs...
2023-06-18 21:06:12 [bash] 
2023-06-18 21:06:12 [bash] Warning: due to a long standing Gtk+ bug
2023-06-18 21:06:12 [bash] https://gitlab.gnome.org/GNOME/gtk/issues/221
2023-06-18 21:06:12 [bash] Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.
2023-06-18 21:06:12 [bash] Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.
2023-06-18 21:06:13 [bash] Loading time (native compiled elisp)...
2023-06-18 21:06:13 [bash] Loading time (native compiled elisp)...done
2023-06-18 21:06:13 [bash] Loading /home/maxim/.emacs.d/recentf...
2023-06-18 21:06:13 [bash] Loading /home/maxim/.emacs.d/recentf...done
2023-06-18 21:06:13 [bash] Cleaning up the recentf list...
2023-06-18 21:06:13 [bash] Cleaning up the recentf list...done (0 removed)
2023-06-18 21:06:13 [bash] .emacs: Warning: Use keywords rather than deprecated positional arguments to `define-minor-mode'
2023-06-18 21:06:15 [bash] Preparing diary...
2023-06-18 21:06:15 [bash] No diary entries for Sunday, June 18, 2023: Father's Day
2023-06-18 21:06:15 [bash] Preparing diary...done
2023-06-18 21:06:15 [bash] Appointment reminders enabled
2023-06-18 21:06:16 [bash] Loading /home/maxim/.emacs.d/emms/cache...
2023-06-18 21:06:16 [bash] Loading /home/maxim/.emacs.d/emms/cache...done
2023-06-18 21:06:18 [bash] [yas] Prepared just-in-time loading of snippets successfully.
2023-06-18 21:06:20 [bash] [yas] Prepared just-in-time loading of snippets successfully.
2023-06-18 21:06:22 [bash] Starting new Ispell process aspell with english dictionary... \ 
2023-06-18 21:06:22 [bash] Starting new Ispell process aspell with english dictionary...done
2023-06-18 21:06:22 [bash] Starting Emacs daemon.
--8<---------------cut here---------------end--------------->8---

-- 
Thanks,
Maxim