kemoverse/startup.sh
w e1c3f0e50b Add environment mode support and WSGI configuration
- Introduced environment mode variable to control bot and web server behavior.
- Updated startup script to run Gunicorn in production mode and Flask in development mode.
- Created a new WSGI entry point for the web application.
2025-07-18 00:44:11 -03:00

51 lines
1.5 KiB
Bash
Executable file

#!/bin/bash
# Kemoverse - a gacha-style bot for the Fediverse.
# Copyright © 2025 Waifu and VD15
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see https://www.gnu.org/licenses/.
# Navigate to the project directory (optional)
cd "$(dirname "$0")"
# Activate virtual environment
source venv/bin/activate
# Read the environment mode
ENV_MODE=${KEMOVERSE_ENV:-prod}
echo "Running in '$ENV_MODE' mode..."
# 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..."
if [ "$ENV_MODE" = "dev" ]; then
python3 web/app.py &
else
gunicorn -w 4 -b 127.0.0.1:8000 web.wsgi:app &
fi
# 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