all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bruno Victal <mirai@makinata.eu>
To: 63190@debbugs.gnu.org
Cc: mirai@makinata.eu, bjc@spork.org
Subject: bug#63190: [Shepherd] Nested calls lead to a hang
Date: Sun, 30 Apr 2023 16:21:14 +0100	[thread overview]
Message-ID: <f25fee95-7b68-88e5-85ec-77322afa29ac@makinata.eu> (raw)

Original discussion (IRC): <https://logs.guix.gnu.org/guix/2023-04-29.log#180735>


Minimal example (annotated):

test-system.scm:
--8<---------------cut here---------------start------------->8---
(use-modules (gnu)
             (gnu tests)
             (gnu packages)
             (gnu packages base) ; coreutils/sleep
             (gnu packages admin)  ; shepherd
             (gnu services shepherd))

;; Some dummy service whose start action simply waits for some seconds,
;; about enough to check with herd status before it exits.
(define dummy-service-type
  (shepherd-service-type
   'dummy
   (lambda (cfg)
     (shepherd-service
      (documentation "Dummy action to start service.")
      (provision '(dummy-service))
      (respawn? #f)    ; <<<<<< note, this disables the service!
      (modules (cons* '(gnu services herd)
                      %default-modules))
      (start #~(lambda _
                 (format #t "Starting a delay on dummy service.~%")
                 (fork+exec-command (list #$(file-append coreutils "/bin/sleep")
                                          "30"))))
      (stop #~(make-kill-destructor))
      (actions
       (list (shepherd-action
              (name 'my-action)
              (documentation "lorem ipsum")
              (procedure
               #~(lambda (x)
                   ;; Scenario 1: using code from (gnu services herd), this hangs shepherd
                   #;(start-service 'dummy)  ; hangs shepherd
                   ;; Scenario 2: this doesn't hang shepherd but do note that the service has to be re-enabled either manually or automatically here
                   #;(system* #$(file-append shepherd "/bin/herd") "start" "dummy-service")
                   ;; Scenario 3: use the already imported (shepherd service) module, doesn't hang shepherd
                   ;;             Like Scenario 2, the service must be re-enabled since (respawn? #f) disabled this.
                   ;;             Comment: Won't re-enabling mean that this service will relaunch once it quits?
                   ;;                      That means the service has to disable itself on a successful exit, perhaps within the (stop ...) field?
                   (start 'dummy-service))))))))
   #f  ; no config
   (description "lorem ipsum.")))

(operating-system
  (inherit %simple-os)
  (services
   (cons*
    (service dummy-service-type)
    %base-services)))

--8<---------------cut here---------------end--------------->8---


Required modifications to gnu/services/shepherd.scm for scenario 1:

--8<---------------cut here---------------start------------->8---
diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm
index b2601c0128..158806f421 100644
--- a/gnu/services/shepherd.scm
+++ b/gnu/services/shepherd.scm
@@ -282,7 +282,8 @@ (define (shepherd-service-file-name service)
 
 (define (shepherd-service-file service)
   "Return a file defining SERVICE."
   (scheme-file (shepherd-service-file-name service)
-               (with-imported-modules %default-imported-modules
+               (with-imported-modules (cons '(gnu services herd)
+                                            %default-imported-modules)
                  #~(begin
                      (use-modules #$@(shepherd-service-modules service))
--8<---------------cut here---------------end--------------->8---




             reply	other threads:[~2023-04-30 15:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-30 15:21 Bruno Victal [this message]
2023-05-06 17:26 ` bug#63190: [Shepherd] Nested calls lead to a hang Ludovic Courtès
2023-05-08 10:27   ` Ludovic Courtès
2023-05-12 23:01   ` Brian Cully via Bug reports for GNU Guix
2023-05-13  9:45     ` Ludovic Courtès

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f25fee95-7b68-88e5-85ec-77322afa29ac@makinata.eu \
    --to=mirai@makinata.eu \
    --cc=63190@debbugs.gnu.org \
    --cc=bjc@spork.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.