From patchwork Mon Sep 21 15:26:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helmut Schaa X-Patchwork-Id: 520336 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5509A140180 for ; Tue, 22 Sep 2015 01:27:04 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=googlemail.com header.i=@googlemail.com header.b=TxPWKHSd; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id F12F8289C9A; Mon, 21 Sep 2015 17:25:39 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 63BA42845AF for ; Mon, 21 Sep 2015 17:25:32 +0200 (CEST) X-policyd-weight: using cached result; rate:hard: -8.5 Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Mon, 21 Sep 2015 17:25:31 +0200 (CEST) Received: by wicfx3 with SMTP id fx3so116834275wic.0 for ; Mon, 21 Sep 2015 08:26:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=am4teNRegmCrVNIAMmFTQ5zKGDYeSRST1UnL83yDZIk=; b=TxPWKHSdJ7IUDJFI2JR4jUnzeudgHm63OXLhmlXsSDGUmrnCbmm38trXnmrFlozNsI jl7x5tuR9R/al6lYdfgIcbOlEjj8n4qYgTGAftttR74pQwvhO89pRpkuAfpvhzgtG+Ye 2hdUOPVwqgcPVCFyPbltSZY6ADYCMuIhu3bWnzkzfOLOHxPlzMyCGbbHCekmidAa9JzD sjaFMOD9hCcrDLa0B2tM5trIr07yJhSNYjtQ1zoSQQo+KzVw1q9mUBnk5suGgeeJnUjO j7+kbF95SY5tt6W/KYtqMYLfsSz9aLOACvzk1cIWCYVyrVgRkmA1BYiFW6amf8Py88Sp sVbg== X-Received: by 10.180.107.130 with SMTP id hc2mr13084293wib.92.1442849203688; Mon, 21 Sep 2015 08:26:43 -0700 (PDT) Received: from hschaa-desktop.site (HSI-KBW-217-008-059-040.hsi.kabelbw.de. [217.8.59.40]) by smtp.gmail.com with ESMTPSA id ft3sm14001628wib.17.2015.09.21.08.26.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Sep 2015 08:26:42 -0700 (PDT) From: Helmut Schaa To: openwrt-devel@lists.openwrt.org Date: Mon, 21 Sep 2015 17:26:23 +0200 Message-Id: <1442849183-9418-1-git-send-email-helmut.schaa@googlemail.com> X-Mailer: git-send-email 1.8.4.5 Subject: [OpenWrt-Devel] [RFC] procd: Allow to enable endless respawning of services X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Extend /etc/config/system with a parameter to enable infinite respawn mode: config system option service_endless_respawn 1 All services that don't specify specific respawn parameters will get their defaults added by procd.sh and if service_endless_respawn is set respawn_retry will be set to -1. This makes procd to respawn the service forever. Signed-off-by: Helmut Schaa --- package/system/procd/files/procd.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/package/system/procd/files/procd.sh b/package/system/procd/files/procd.sh index e83e75c..04111b9 100644 --- a/package/system/procd/files/procd.sh +++ b/package/system/procd/files/procd.sh @@ -316,6 +316,18 @@ _procd_append_param() { } _procd_close_instance() { + local respawn_vals + if json_select respawn ; then + json_get_values respawn_vals + if [ -z "$respawn_vals" ]; then + # Set respawn defaults + local respawn_retry + [[ -n "$(uci_get system.@system[0].service_endless_respawn)" ]] && respawn_retry=-1 + _procd_add_array_data 3600 5 ${respawn_retry:-5} + fi + json_select .. + fi + json_close_object }