#!/bin/bash

# Navigate to the project directory (optional)
cd "$(dirname "$0")"

# Activate virtual environment
source venv/bin/activate

# Start the bot
echo "Starting bot..."
python3 bot/bot_app.py &

# Save the bot PID so you can stop it later if needed
BOT_PID=$!

# Start the website
echo "Starting web server..."
python3 web/app.py &

# Save the web PID too
WEB_PID=$!

# On CTRL+C or termination, kill both
trap "echo 'Stopping...'; kill $BOT_PID $WEB_PID; exit" SIGINT SIGTERM

# Wait for both processes (if you want it to stay attached)
wait $BOT_PID $WEB_PID