Files
TG-GDrive-2/run_bot.sh
T
arsam 7363b7608a Import source: run_bot.sh
Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality.
2026-09-18 23:15:44 +03:30

20 lines
679 B
Bash

#!/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