#!/bin/bash
# restart_bot.sh
# Safe bot restart -- no git operations, just kills and relaunches.
# Called by watcher cmd payload. Git sync is handled by the watcher itself.
cd /home/opc/trading
source venv/bin/activate
pkill -f "python3.11.*StockTrading" 2>/dev/null || true
sleep 3
nohup python3.11 /home/opc/trading/StockTrading.py > /home/opc/trading/trading.log 2>&1 &
echo "Bot restarted PID=$!"
sleep 8
pgrep -fa StockTrading && echo "CONFIRMED RUNNING" || echo "WARNING: bot not detected"
tail -15 /home/opc/trading/trading.log
