From patchwork Wed Apr 24 15:56:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adolf Belka X-Patchwork-Id: 7758 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4VPkBq5NMcz3wwD for ; Wed, 24 Apr 2024 15:57:07 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4VPkBn5RFcz1s4; Wed, 24 Apr 2024 15:57:05 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4VPkBn3GNvz32mZ; Wed, 24 Apr 2024 15:57:05 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4VPkBk515Qz2y89 for ; Wed, 24 Apr 2024 15:57:02 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4VPkBj5zWzz1v; Wed, 24 Apr 2024 15:57:01 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1713974221; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ZsF5DmFX2SFJaP8a9QvLg5B5rgc8jC/iYabvn6vOXIw=; b=KOgrWxFoHxw9tox+6jvKlMueYDdGkVlVk7vFXmN22VAwpmrOJ4tNTD4wQS3w5kpGBvFGjR j7iyHImPCbtFU+Dw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1713974221; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ZsF5DmFX2SFJaP8a9QvLg5B5rgc8jC/iYabvn6vOXIw=; b=kfFF6ZkyAnxbkhy3DpEXKMsaX8lNbsriXzfE+j2S6G5UWPmkS4YAzl5s0IxeyiMW7AwKeL E2XP5A7pemI9TpuIhoCSSV5gDZUfu171+WQgtHytzBxwg6RS/1UQGgmSb2dg8ir4BsdyNc EMm63jR5qv88BUG/hb1kK8653zrEN3LBEN5fJtkOAyw3fXMEtqW65z3TUmHtVx195WujYK Uk3aCPyNp/TJZAwNaz3uYZBmjcux7kDVDCK0wSyiywQBlOCw8um71sdtlbilHjaag01tHj catYXEWeqmimOwKeBjaGml/LUfZmXZr3C5EgfHbE8f/e2OKrDRQ6b0Qkb4rmKw== From: Adolf Belka To: development@lists.ipfire.org Subject: [PATCH] apache: Fixes bug13656 - Add delay between stop & start of restart command. Date: Wed, 24 Apr 2024 17:56:51 +0200 Message-ID: <20240424155651.3426712-1-adolf.belka@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: PXKJAVQPQDXHGX2H2HITI7X462SEELTI X-Message-ID-Hash: PXKJAVQPQDXHGX2H2HITI7X462SEELTI X-MailFrom: adolf.belka@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: - The change of the apache initscript in CU181 made the restart comand a stop followed by a start. From bug13656 it looks like when the start is run the pid file may not yet be fully removed and so apache is not started, although the pid is being removed. - This patch checks if the pid file is still present every second up to 10 seconds. Once the pid file is gone then the stop command is completed and the initscript moves to the start command. - Rather than apply a fixed delay of 2 or 3 or 4 seconds I used a while loop to check every second if the file is still present. If at the end of 10 seconds it is still present then something went wrong with the pid removal. - I have tested this patch on my vm system and it worked but it would be good to be reviewed to make sure that it is a reasonable approach that has been used and if required changed in whatever way makes the best sense. Fixes: Bug13656 Tested-by: Adolf Belka Signed-off-by: Adolf Belka --- src/initscripts/system/apache | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/initscripts/system/apache b/src/initscripts/system/apache index 18eb86e2f..087e4084e 100644 --- a/src/initscripts/system/apache +++ b/src/initscripts/system/apache @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2022 IPFire Team # +# Copyright (C) 2007-2024 IPFire Team # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -87,6 +87,16 @@ case "$1" in stop) boot_mesg "Stopping Apache daemon..." /usr/sbin/apachectl -k stop + COUNTER=0 + while [ -e /var/run/httpd.pid ] + do + sleep 1 + (( COUNTER++ )) + if [ $COUNTER -eq 10 ]; then + boot_mesg "pid not removed after 10 seconds" + break + fi + done evaluate_retval ;;