PostgreSQL + async refactoring, WebSocket server, Redis caching, minified assets
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
# CS2 Simulator — Production Start Script
|
||||
# Starts: PostgreSQL-backed web app + WebSocket server
|
||||
|
||||
set -e
|
||||
|
||||
# Ensure PostgreSQL is running
|
||||
pg_isready -q || service postgresql start
|
||||
|
||||
# Ensure Redis is running
|
||||
redis-cli ping > /dev/null 2>&1 || redis-server --daemonize yes
|
||||
|
||||
# Set production env
|
||||
export USE_ASYNC=1
|
||||
export ASYNC_DATABASE_URL="${ASYNC_DATABASE_URL:-postgresql+asyncpg://dodep:dodep123@localhost/dodep}"
|
||||
export REDIS_URL="${REDIS_URL:-redis://localhost:6379/0}"
|
||||
|
||||
echo "=== Starting CS2 Simulator ==="
|
||||
echo "DB: $ASYNC_DATABASE_URL"
|
||||
echo "WS Server: port 13670"
|
||||
echo "Web App: port 13669"
|
||||
|
||||
# Kill old processes
|
||||
pkill -f "uvicorn frontend:app" 2>/dev/null || true
|
||||
pkill -f "uvicorn ws_server:app" 2>/dev/null || true
|
||||
sleep 1
|
||||
|
||||
# Start WebSocket server
|
||||
nohup venv/bin/python -m uvicorn ws_server:app --host 0.0.0.0 --port 13670 --workers 1 > ws_server.log 2>&1 &
|
||||
echo "[WS] Started on port 13670"
|
||||
|
||||
# Start main web app with multiple workers
|
||||
nohup venv/bin/python -m uvicorn frontend:app --host 0.0.0.0 --port 13669 --workers 4 --loop uvloop > frontend.log 2>&1 &
|
||||
echo "[WEB] Started on port 13669 (4 workers)"
|
||||
|
||||
echo "=== Ready ==="
|
||||
echo "Web: http://localhost:13669"
|
||||
echo "WS: ws://localhost:13670/ws/{user_id}"
|
||||
Reference in New Issue
Block a user