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.
This commit is contained in:
parent
3a8b10c787
commit
e1c3f0e50b
4 changed files with 33 additions and 3 deletions
|
@ -22,6 +22,10 @@ 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 &
|
||||
|
@ -31,7 +35,11 @@ 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=$!
|
||||
|
|
0
web/__init__.py
Normal file
0
web/__init__.py
Normal file
|
@ -108,5 +108,9 @@ def player_list():
|
|||
return render_template('player_list.html', players=[])
|
||||
return render_template('player_list.html', players=players)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host=config.BIND_ADDRESS, port=config.WEB_PORT, debug=True)
|
||||
if __name__ == '__main__' and os.environ.get("KEMOVERSE_ENV") == "dev":
|
||||
app.run(
|
||||
host=config.BIND_ADDRESS,
|
||||
port=config.WEB_PORT,
|
||||
debug=True,
|
||||
)
|
18
web/wsgi.py
Normal file
18
web/wsgi.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
#Kemoverse - a gacha-style bot for the Fediverse.
|
||||
#Copyright © 2025 Waifu
|
||||
#
|
||||
#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/.
|
||||
|
||||
from .app import app
|
||||
|
Loading…
Add table
Reference in a new issue