diff mbox series

[bug#71263,4/5] gnu: docker: Allow setting Shepherd respawn? in oci-container-configuration.

Message ID 4e9095471f8157305cb7b0e26cacd6580de344c2.1717018736.git.goodoldpaul@autistici.org
State New
Headers show
Series [bug#71263,1/5] doc: Minor changes to the OCI-backed Services documentation. | expand

Commit Message

Giacomo Leidi May 29, 2024, 9:38 p.m. UTC
* gnu/services/docker.scm (oci-container-configuration)
[respawn?]: New field;
(oci-container-shepherd-service): use it.

Change-Id: I0d6367607fd0fd41f90a54b33d80bf4d4f43dd8b
---
 doc/guix.texi           | 4 ++++
 gnu/services/docker.scm | 9 ++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index dfc4d65349..9abdc77869 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -40653,6 +40653,10 @@  Miscellaneous Services
 Whether this service should be started automatically by the Shepherd.  If it
 is @code{#f} the service has to be started manually with @command{herd start}.
 
+@item @code{respawn?} (default: @code{#f}) (type: boolean)
+Whether to have Shepherd restart the service when it stops, for instance when
+the underlying process dies.
+
 @item @code{network} (default: @code{""}) (type: string)
 Set a Docker network for the spawned container.
 
diff --git a/gnu/services/docker.scm b/gnu/services/docker.scm
index 712ca14cba..bc566e6316 100644
--- a/gnu/services/docker.scm
+++ b/gnu/services/docker.scm
@@ -76,6 +76,7 @@  (define-module (gnu services docker)
             oci-container-configuration-requirement
             oci-container-configuration-log-file
             oci-container-configuration-auto-start?
+            oci-container-configuration-respawn?
             oci-container-configuration-network
             oci-container-configuration-ports
             oci-container-configuration-volumes
@@ -472,6 +473,10 @@  (define-configuration/no-serialization oci-container-configuration
    (boolean #t)
    "Whether this service should be started automatically by the Shepherd.  If it
 is @code{#f} the service has to be started manually with @command{herd start}.")
+  (respawn?
+   (boolean #f)
+   "Whether to restart the service when it stops, for instance when the
+underlying process dies.")
   (network
    (maybe-string)
    "Set a Docker network for the spawned container.")
@@ -685,6 +690,8 @@  (define (oci-container-shepherd-service config)
          (log-file (oci-container-configuration-log-file config))
          (provision (oci-container-configuration-provision config))
          (requirement (oci-container-configuration-requirement config))
+         (respawn?
+          (oci-container-configuration-respawn? config))
          (image (oci-container-configuration-image config))
          (image-reference (oci-image-reference image))
          (options (oci-container-configuration->options config))
@@ -697,7 +704,7 @@  (define (oci-container-shepherd-service config)
 
     (shepherd-service (provision `(,(string->symbol name)))
                       (requirement `(dockerd user-processes ,@requirement))
-                      (respawn? #f)
+                      (respawn? respawn?)
                       (auto-start? auto-start?)
                       (documentation
                        (string-append