feat(worker): Enhance db_worker script for better error handling and add systemd service example

This commit is contained in:
Ross
2026-05-17 21:36:46 +01:00
parent c2d8376e22
commit d77c5149f0
4 changed files with 130 additions and 91 deletions
+8 -2
View File
@@ -23,10 +23,16 @@ echo "Python: $PYTHON_BIN"
while true; do
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] Launching db_worker"
"$PYTHON_BIN" "$ROOT_DIR/manage.py" db_worker
exit_code=$?
if "$PYTHON_BIN" "$ROOT_DIR/manage.py" db_worker; then
exit_code=0
else
exit_code=$?
fi
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] db_worker exited with code $exit_code"
if [ "$exit_code" -eq 137 ] || [ "$exit_code" -eq 9 ]; then
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] db_worker appears to have been SIGKILL'ed (likely OOM)." >&2
fi
if [ "$MAX_RESTARTS" -gt 0 ] && [ "$restart_count" -ge "$MAX_RESTARTS" ]; then
echo "Max restarts reached ($MAX_RESTARTS). Exiting." >&2