Subject: shepherd not working out of the box in Debian

From: [email-masked]
Date: Mon, 09 Dec 2019 21:51:41 +0100

I run shepherd 0.6.1 (with guile 2.2.4) as the init system for Debian
buster. It's an installation in the standard place /usr/local.

When /usr/local/var/run/shepherd/socket is left dangling due to a crash,
shepherd won't start on the next reboot, as error SOCADDRINUSE is
raised.

Obviously this won't happen if --prefix is / and /var/run points to a
volatile file system, but chosing that prefix is probably not what
someone trying to test shepherd will do.

Below is my patch:

*** shepherd.scm	2019-12-08 18:11:19.820000000 +0000
--- shepherd.scm-ORI	2019-04-18 10:39:12.000000000 +0100
***************
*** 46,51 ****
        (fcntl sock F_SETFL (logior O_NONBLOCK
                                    (fcntl sock F_GETFL)))
-       ;; if file-name is still there, SOCADDRINUSE error is triggered
-       (when (file-exists? file-name) (delete-file file-name))
        (bind sock address)
        (listen sock 10)
--- 46,49 ----
***************
*** 186,191 ****
                     (%current-logfile-date-format
                      (if (and (not logfile) (zero? (getuid)))
! 			;; for syslog, first 2 characters are truncated
!                         (format #f "  shepherd[~d]: " (getpid))
                          default-logfile-date-format))
                     (current-output-port
--- 184,188 ----
                     (%current-logfile-date-format
                      (if (and (not logfile) (zero? (getuid)))
!                         (format #f "shepherd[~d]: " (getpid))
                          default-logfile-date-format))
                     (current-output-port

Notice the second patch, which corrects these kind of output in
/var/syslog:

Dec  9 20:18:18 buster cron[567]: (CRON) STARTUP (fork ok)
Dec  9 20:18:18 buster cron[567]: (CRON) INFO (Running @reboot jobs)
Dec  9 20:18:18 buster epherd[1]: Service sshd has been started.
Dec  9 20:18:18 buster epherd[1]: Service hwclock is already running.
Dec  9 20:18:18 buster epherd[1]: Service sendsigs is already running.
Dec  9 20:18:18 buster epherd[1]: Service hostname is already running.
Dec  9 20:18:18 buster epherd[1]: Service mountall-bootclean is already running.
Dec  9 20:18:19 buster rsyslogd:  [origin software="rsyslogd" swVersion="8.1901.0" x-pid="556" x-info="https://www.rsyslog.com"] start
Dec  9 20:23:18 buster anacron[562]: Job `cron.daily' started
Dec  9 20:23:18 buster anacron[625]: Updated timestamp for job `cron.daily' to 2019-12-09

-- 

Bernard