From cd7889554a8397abdd973984faae939b93b175b4 Mon Sep 17 00:00:00 2001 From: Lars Erik Wik Date: Wed, 27 May 2026 13:09:52 +0200 Subject: [PATCH] cf-execd.service: drain cf-agent on stop `KillMode=process` only signals cf-execd. Any cf-agent spawned by cf-execd keeps running after systemctl stop returns. A mid-run agent can then re-trigger cf-php-fpm (`Wants=cf-postgres`), causing dependencies to be pulled back in after the stop was reported successful. This fix adds `ExecStopPost=` that waits up to 60s for cf-agent to drain, then `SIGKILL`s any survivor. It runs after cf-execd has exited, so no new agents are spawned during the drain. Ticket: ENT-14108 Changelog: cf-execd systemctl stop now waits for in-flight cf-agent to finish Signed-off-by: Lars Erik Wik --- misc/systemd/cf-execd.service.in | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/misc/systemd/cf-execd.service.in b/misc/systemd/cf-execd.service.in index 66f1e235e3..6ffb1c8bba 100644 --- a/misc/systemd/cf-execd.service.in +++ b/misc/systemd/cf-execd.service.in @@ -12,5 +12,14 @@ Restart=always RestartSec=10 KillMode=process +# Drain in-flight cf-agent, so it does not pull dependencies back in after the +# stop is reported successful (as seen in ENT-14108). +ExecStopPost=/bin/sh -c 't=60; \ + while [ $$t -gt 0 ] && pgrep -x cf-agent >/dev/null 2>&1; do \ + sleep 1; \ + t=$$((t - 1)); \ + done; \ + pkill -KILL -x cf-agent >/dev/null 2>&1 || true' + [Install] WantedBy=multi-user.target