Subject: Re: bug#52654: shepherd lacks error reporting

From: Maxim Cournoyer <[email-masked]>
Date: Sat, 29 Apr 2023 11:22:27 -0400

Hi,

I also encountered that issue, it's really puzzling.

Here's the problematic start slot that got my mpd test to hang the boot,
with the last message being "Please wait while gathering entropy to
generate the key pair;":

--8<---------------cut here---------------start------------->8---
(start
        (with-imported-modules (source-module-closure
                                '((gnu build activation)))
          #~(begin
              (use-modules (gnu build activation))

              (let ((user (getpw #$username)))

                (define (init-directory directory)
                  (unless (file-exists? directory)
                    (mkdir-p/perms directory user #o755)))

                (for-each
                 init-directory
                 (cons '#$(map dirname
                               ;; XXX: Delete the potential "syslog"
                               ;; log-file value, which is not a directory.
                               (delete "syslog"
                                       (filter-map maybe-value
                                                   (list db-file
                                                         log-file
                                                         state-file
                                                         sticker-file)))))))

              (make-forkexec-constructor
               (list #$(file-append package "/bin/mpd") "--no-daemon"
                     #$config-file)
               #:environment-variables '#$environment-variables))))
--8<---------------cut here---------------end--------------->8---

The error was the lonely cons.  Taking it out, the test then passed:

--8<---------------cut here---------------start------------->8---
(start
        (with-imported-modules (source-module-closure
                                '((gnu build activation)))
          #~(begin
              (use-modules (gnu build activation))

              (let ((user (getpw #$username)))

                (define (init-directory directory)
                  (unless (file-exists? directory)
                    (mkdir-p/perms directory user #o755)))

                (for-each
                 init-directory
                 '#$(map dirname
                         ;; XXX: Delete the potential "syslog"
                         ;; log-file value, which is not a directory.
                         (delete "syslog"
                                 (filter-map maybe-value
                                             (list db-file
                                                   log-file
                                                   state-file
                                                   sticker-file))))))

              (make-forkexec-constructor
               (list #$(file-append package "/bin/mpd") "--no-daemon"
                     #$config-file)
               #:environment-variables '#$environment-variables))))
--8<---------------cut here---------------end--------------->8---

Shepherd should report the error, fail that one service and attempt to
keep booting (if the service is not required by other critical ones).

-- 
Thanks,
Maxim