From patchwork Wed May 29 21:38:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giacomo Leidi X-Patchwork-Id: 64941 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 4223027BBE9; Wed, 29 May 2024 22:40:39 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 5FF3C27BBE2 for ; Wed, 29 May 2024 22:40:37 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCR1b-0000p6-8t; Wed, 29 May 2024 17:39:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sCR1Y-0000ng-CD for guix-patches@gnu.org; Wed, 29 May 2024 17:39:56 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sCR1Y-0001oh-3E; Wed, 29 May 2024 17:39:56 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sCR1h-0008Do-Ja; Wed, 29 May 2024 17:40:05 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71263] [PATCH 4/5] gnu: docker: Allow setting Shepherd respawn? in oci-container-configuration. Resent-From: Giacomo Leidi Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, ludo@gnu.org, matt@excalamus.com, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Wed, 29 May 2024 21:40:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71263 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 71263@debbugs.gnu.org Cc: Giacomo Leidi , Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer X-Debbugs-Original-Xcc: Florian Pelz , Ludovic =?utf-8?q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer Received: via spool by 71263-submit@debbugs.gnu.org id=B71263.171701877731471 (code B ref 71263); Wed, 29 May 2024 21:40:05 +0000 Received: (at 71263) by debbugs.gnu.org; 29 May 2024 21:39:37 +0000 Received: from localhost ([127.0.0.1]:55975 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sCR1E-0008BP-W6 for submit@debbugs.gnu.org; Wed, 29 May 2024 17:39:37 -0400 Received: from confino.investici.org ([93.190.126.19]:65325) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sCR18-0008Ae-VX for 71263@debbugs.gnu.org; Wed, 29 May 2024 17:39:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1717018753; bh=eZhzPJEy3x83M2TJUQ+npHboyeD6jAJdPdkmO9YBH80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=usFSn410w/S3gKZCVbR6q6VLSUEE5r/t5dnZd88IEdcPjC35UoWMUsK9lTzdO0rsK gsmzTukVNC466z+BLfbxDzWfa1QU54KufCC0aS6o2pG+2+V/ZoYxge34I2nrYEFdef F9tYUfSmZWv72W2TZRtffcwHTAWC9HQ+qDEKmJi0= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4VqN7P0vTLz1116; Wed, 29 May 2024 21:39:13 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4VqN7P0LFLz110x; Wed, 29 May 2024 21:39:13 +0000 (UTC) Date: Wed, 29 May 2024 23:38:55 +0200 Message-ID: <4e9095471f8157305cb7b0e26cacd6580de344c2.1717018736.git.goodoldpaul@autistici.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <31ff6a93a8c7b50e5152f75b091b28851d5c4cc8.1717018735.git.goodoldpaul@autistici.org> References: <31ff6a93a8c7b50e5152f75b091b28851d5c4cc8.1717018735.git.goodoldpaul@autistici.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Giacomo Leidi X-ACL-Warn: , Giacomo Leidi via Guix-patches X-Patchwork-Original-From: Giacomo Leidi via Guix-patches via From: Giacomo Leidi Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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 --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