Repository navigation
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·69 lines (57 loc) · 1.81 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·69 lines (57 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# War Thunder Statistics Backend - Render Deployment Script
echo "🚀 Starting War Thunder Statistics Backend deployment..."
# Check if we're in the right directory
if [ ! -f "backend/main.py" ]; then
echo "❌ Error: Please run this script from the project root directory"
exit 1
fi
# Set environment variables for production
export ENVIRONMENT=production
export PYTHON_VERSION=3.11.0
export PORT=8000
# Install dependencies
echo "📦 Installing dependencies..."
cd backend
pip install -r requirements.txt
# Run health check
echo "🏥 Running health check..."
python -c "
import asyncio
import httpx
import time
async def health_check():
try:
async with httpx.AsyncClient() as client:
response = await client.get('http://localhost:8000/health', timeout=10)
if response.status_code == 200:
print('✅ Health check passed')
return True
else:
print(f'❌ Health check failed: {response.status_code}')
return False
except Exception as e:
print(f'❌ Health check error: {e}')
return False
# Start server in background
import subprocess
import threading
import time
def start_server():
subprocess.run(['uvicorn', 'main:app', '--host', '0.0.0.0', '--port', '8000'])
server_thread = threading.Thread(target=start_server, daemon=True)
server_thread.start()
# Wait for server to start
time.sleep(5)
# Run health check
result = asyncio.run(health_check())
if result:
print('🎉 Deployment successful!')
print('📊 API Documentation: http://localhost:8000/docs')
print('🔍 Health Check: http://localhost:8000/health')
print('📈 Metrics: http://localhost:8000/metrics')
else:
print('💥 Deployment failed!')
exit(1)
"
echo "✅ Deployment script completed!"