From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 14716 invoked from network); 29 Jul 2021 11:33:11 -0000 Received: from alyss.skarnet.org (95.142.172.232) by inbox.vuxu.org with ESMTPUTF8; 29 Jul 2021 11:33:11 -0000 Received: (qmail 28648 invoked by uid 89); 29 Jul 2021 11:33:35 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Received: (qmail 28641 invoked from network); 29 Jul 2021 11:33:35 -0000 From: "Laurent Bercot" To: "Arjun D R" , supervision@list.skarnet.org Subject: Re: Query on S6 system shutdown Date: Thu, 29 Jul 2021 11:33:08 +0000 Message-Id: In-Reply-To: References: Reply-To: "Laurent Bercot" User-Agent: eM_Client/8.2.1473.0 Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvtddrheefgddthecutefuodetggdotffvucfrrhhofhhilhgvmecupfgfoffgtffkveetuefngfdpqfgfvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkfgjfhhrfgggtgfgsehtqhertddtreejnecuhfhrohhmpedfnfgruhhrvghnthcuuegvrhgtohhtfdcuoehskhgrqdhsuhhpvghrvhhishhiohhnsehskhgrrhhnvghtrdhorhhgqeenucggtffrrghtthgvrhhnpedvgfevffeuleegvdektdffteegvdeiieefkeetgfeuheffheelheejhfevueeijeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphhouhht >I believe the finish script is not being called by s6-svc. When I run it >manually , the finish script runs and kills the process and graceful >shutdown is happening as expected. > >What may be the cause for not triggering the finish script of critical >service. The finish script, which is entirely optional, is not supposed to kill the process. It is not called by s6-svc, and does not run when the process is still alive. It is *not* equivalent to the "down" script of a oneshot. (There is a subtle hint in the fact that the scripts are named "run" and "finish" instead of "up" and "down".) If it exists, the finish script is run by s6-supervise *after* the service dies. The point is to perform any potentially needed cleanups that are not automatically performed at service death. Your current finish script is entirely incorrect and you should delete it. In order to kill your service, you need to send it a signal. Daemons normally have a signal that tells them to gracefully exit; for most daemons, it is SIGTERM, which is what svc -d sends by default. If your critical.service does not die on s6-svc -d, it means that it ignores SIGTERM. Then you need to find out *what* signal it interprets as a request for a graceful shutdown, and put the name of this signal in the "down-signal" file in your service definition directory. Then, when you send s6-svc -d, critical.service will receive the signal you indicated. down-signal can be SIGKILL - this is what you're using at the moment - but if your service is that critical, chances are it's not the best way to kill it and you should look for a gentler signal to send it first. If there are cases where a graceful exit request is ignored or takes too long, and you want to make sure the service dies at some point, you can create a "timeout-kill" file, containing a number of=20 milliseconds - if the process is still alive after that duration after receiving its down-signal, it will be sent a SIGKILL. -- Laurent