From f26dbdc498615ec4e2cb20cfcfc8de09e95e59fd Mon Sep 17 00:00:00 2001 From: arsam Date: Fri, 18 Sep 2026 23:15:10 +0330 Subject: [PATCH] Import source: run_bot.sh Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality. --- run_bot.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 run_bot.sh diff --git a/run_bot.sh b/run_bot.sh new file mode 100644 index 0000000..b4b436e --- /dev/null +++ b/run_bot.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# run_bot.sh — starts bot.py and auto-restarts it on crash +set -euo pipefail + +DIR="$(cd "$(dirname "$0")" && pwd)" +VENV="$DIR/venv/bin/activate" +LOG="$DIR/bot.log" +RETRY_DELAY=5 # seconds to wait before restarting after a crash + +echo "[run_bot] Starting watchdog. Logs → $LOG" | tee -a "$LOG" + +while true; do + echo "[run_bot] $(date -u '+%Y-%m-%d %H:%M:%S UTC') — launching bot.py" | tee -a "$LOG" + source "$VENV" + python -u "$DIR/bot.py" >> "$LOG" 2>&1 || true + EXIT=$? + echo "[run_bot] $(date -u '+%Y-%m-%d %H:%M:%S UTC') — bot.py exited (code $EXIT), restarting in ${RETRY_DELAY}s..." | tee -a "$LOG" + sleep "$RETRY_DELAY" +done