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.
This commit is contained in:
2026-07-05 11:35:44 +02:00
parent 99cd891b1e
commit d0e78e728a
2 changed files with 40 additions and 10 deletions
+30 -4
View File
@@ -184,11 +184,24 @@ 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"
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"
echo "mailcat stopped"
@@ -286,11 +299,24 @@ 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"
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"
echo "mailcat web stopped"
+8 -4
View File
@@ -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.