From d0e78e728a25d1e96dc7587f60cfb92bf9c38c9e Mon Sep 17 00:00:00 2001 From: Hans Wienen Date: Sun, 5 Jul 2026 11:35:44 +0200 Subject: [PATCH] Strengthen plain stop wrappers The prompts used to arrive at this change since the previous commit User reported that the stop_mailcat script does not stop mailcat. Any special observations that may be relevant for version management for this version. Be brief. Plain-mode stop_mailcat.sh and stop_web.sh now wait longer after SIGTERM and fall back to SIGKILL. verplaats_log.json and plan.md were left unstaged. --- deploy_vps.sh | 38 ++++++++++++++++++++++++++++++++------ restart_prompt.md | 12 ++++++++---- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/deploy_vps.sh b/deploy_vps.sh index 037c9bf..a7ac448 100755 --- a/deploy_vps.sh +++ b/deploy_vps.sh @@ -184,10 +184,23 @@ fi if kill -0 "\$pid" 2>/dev/null; then kill "\$pid" - sleep 2 + timeout=20 + while [ "\$timeout" -gt 0 ] && kill -0 "\$pid" 2>/dev/null; do + sleep 1 + timeout=\$((timeout - 1)) + done if kill -0 "\$pid" 2>/dev/null; then - echo "mailcat still running after SIGTERM: \$pid" - exit 1 + echo "mailcat still running after SIGTERM, sending SIGKILL: \$pid" + kill -KILL "\$pid" 2>/dev/null || true + timeout=5 + while [ "\$timeout" -gt 0 ] && kill -0 "\$pid" 2>/dev/null; do + sleep 1 + timeout=\$((timeout - 1)) + done + if kill -0 "\$pid" 2>/dev/null; then + echo "mailcat still running after SIGKILL: \$pid" + exit 1 + fi fi fi "\$RM" -f "\$PID_FILE" @@ -286,10 +299,23 @@ fi if kill -0 "\$pid" 2>/dev/null; then kill "\$pid" - sleep 2 + timeout=20 + while [ "\$timeout" -gt 0 ] && kill -0 "\$pid" 2>/dev/null; do + sleep 1 + timeout=\$((timeout - 1)) + done if kill -0 "\$pid" 2>/dev/null; then - echo "mailcat web still running after SIGTERM: \$pid" - exit 1 + echo "mailcat web still running after SIGTERM, sending SIGKILL: \$pid" + kill -KILL "\$pid" 2>/dev/null || true + timeout=5 + while [ "\$timeout" -gt 0 ] && kill -0 "\$pid" 2>/dev/null; do + sleep 1 + timeout=\$((timeout - 1)) + done + if kill -0 "\$pid" 2>/dev/null; then + echo "mailcat web still running after SIGKILL: \$pid" + exit 1 + fi fi fi "\$RM" -f "\$WEB_PID_FILE" diff --git a/restart_prompt.md b/restart_prompt.md index 7372e1c..cba6a53 100644 --- a/restart_prompt.md +++ b/restart_prompt.md @@ -193,6 +193,7 @@ In `SERVICE_MANAGER=plain` mode: - The sorter appends wrapper stdout/stderr to `$LOG_DIR/daemon.out`. - The web UI appends stdout/stderr to `$LOG_DIR/web.out`. - The daily report wrapper appends stdout/stderr to `$LOG_DIR/daily_report.out`. +- `stop_mailcat.sh` and `stop_web.sh` in plain mode now send SIGTERM, wait up to 20 seconds, then fall back to SIGKILL and wait up to 5 seconds before reporting failure. Before starting services on the NAS: @@ -239,6 +240,8 @@ python3 -m unittest discover -s tests git diff --check ``` +After the plain-mode stop wrapper change, `bash -n deploy_vps.sh` was rerun successfully. + Useful routing sanity check: ```sh @@ -255,7 +258,8 @@ PY Likely next steps: -1. Deploy the Apple Mail link update to the NAS if the user wants it live there. -2. Run `/share/homes/mailcat/mailcat/bin/run_daily_report.sh` manually on the NAS to send a test digest. -3. Open the digest on macOS Mail and verify subject links open local Apple Mail messages. -4. If iOS/web reliability is needed later, add Roundcube links using mailbox plus IMAP UID, or add a read-only Mailcat message viewer. +1. Deploy the Apple Mail link update and strengthened stop wrappers to the NAS. +2. If an already-running sorter will not stop with the old wrapper, stop it manually by reading `$RUN_DIR/mailcat.pid` and sending TERM/KILL to that PID, then remove the stale PID file. +3. Run `/share/homes/mailcat/mailcat/bin/run_daily_report.sh` manually on the NAS to send a test digest. +4. Open the digest on macOS Mail and verify subject links open local Apple Mail messages. +5. If iOS/web reliability is needed later, add Roundcube links using mailbox plus IMAP UID, or add a read-only Mailcat message viewer.