From: Tomas Volf <~@wolfsden.cz>
To: help-guix@gnu.org
Subject: Why is my shepherd service not getting respawned?
Date: Thu, 07 Nov 2024 00:41:42 +0100 [thread overview]
Message-ID: <87fro4aq15.fsf@wolfsden.cz> (raw)
[-- Attachment #1: Type: text/plain, Size: 2504 bytes --]
Hello all.
(To prevent XY problem:) I want to auto-mount NFS file-system, and the
built-in
--8<---------------cut here---------------start------------->8---
(shepherd-requirements '(networking))
--8<---------------cut here---------------end--------------->8---
does not work for me (but let us not get distracted by that). I wrote a
shepherd service to function as a check for networking being actually
up, but it does not get respawned when it fails and I do not understand
why.
This is the service in my operating-system:
--8<---------------cut here---------------start------------->8---
(simple-service
'network-online
shepherd-root-service-type
(list (shepherd-service
(requirement '(networking))
(provision '(network-online))
(documentation "Wait for the network to come up.")
(start #~(lambda _
(let* ((cmd "/run/privileged/bin/ping -qc1 -W1 1.1.1.1")
(status (system cmd)))
(= 0 (status:exit-val status)))))
(one-shot? #t)
;; Try every second.
(respawn-delay 1)
;; Retry forever. Double-quoting is intentional.
(respawn-limit ''(5 . 5)))))
--8<---------------cut here---------------end--------------->8---
Now, when I reboot the machine, I see in the log that the service did
start:
--8<---------------cut here---------------start------------->8---
Nov 7 00:18:20 localhost shepherd[1]: Starting service network-online...
[..]
Nov 7 00:18:20 localhost shepherd[1]: [sh] PING 192.168.0.110 (192.168.0.110): 56 data bytes
Nov 7 00:18:20 localhost shepherd[1]: [sh] /run/privileged/bin/ping: sending packet: Network is unreachable
Nov 7 00:18:20 localhost shepherd[1]: Service network-online could not be started.
Nov 7 00:18:20 localhost shepherd[1]: Service network-online failed to start.
--8<---------------cut here---------------end--------------->8---
The fail on first run is expected, however the problem is it starts
exactly once. I do not see any attempts to respawn it in the
/var/log/messages, but based on the documentation the service *should*
get respawned, since it failed. What am I doing wrong? Would anyone
have any suggestions, either what is wrong with the code above or how to
approach it in another way?
Thank you and have a nice day,
Tomas
--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 853 bytes --]
reply other threads:[~2024-11-06 23:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fro4aq15.fsf@wolfsden.cz \
--to=~@wolfsden.cz \
--cc=help-guix@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).