This adds a complete production deployment setup using Gunicorn as the WSGI server, replacing Flask's development server. Key components: - Gunicorn configuration with optimized worker settings - Support for sync, threaded, and async (gevent) workers - Automatic worker recycling to prevent memory leaks - Increased timeouts for audio processing - Production-ready logging and monitoring Deployment options: 1. Docker/Docker Compose for containerized deployment 2. Systemd service for traditional deployment 3. Nginx reverse proxy configuration 4. SSL/TLS support Production features: - wsgi.py entry point for WSGI servers - gunicorn_config.py with production settings - Dockerfile with multi-stage build - docker-compose.yml with full stack (Redis, PostgreSQL) - nginx.conf with caching and security headers - systemd service with security hardening - deploy.sh automated deployment script Configuration: - .env.production template with all settings - Support for environment-based configuration - Separate requirements-prod.txt - Prometheus metrics endpoint (/metrics) Monitoring: - Health check endpoints for liveness/readiness - Prometheus-compatible metrics - Structured logging - Memory usage tracking - Request counting Security: - Non-root user in Docker - Systemd security restrictions - Nginx security headers - File permission hardening - Resource limits Documentation: - Comprehensive PRODUCTION_DEPLOYMENT.md - Scaling strategies - Performance tuning guide - Troubleshooting section Also fixed memory_manager.py GC stats collection error. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
34 lines
905 B
Python
34 lines
905 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
WSGI entry point for production deployment
|
|
"""
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Add the project directory to the Python path
|
|
project_root = Path(__file__).parent.absolute()
|
|
sys.path.insert(0, str(project_root))
|
|
|
|
# Set production environment
|
|
os.environ['FLASK_ENV'] = 'production'
|
|
|
|
# Import and configure the Flask app
|
|
from app import app
|
|
|
|
# Production configuration overrides
|
|
app.config.update(
|
|
DEBUG=False,
|
|
TESTING=False,
|
|
# Ensure proper secret key is set in production
|
|
SECRET_KEY=os.environ.get('SECRET_KEY', app.config.get('SECRET_KEY'))
|
|
)
|
|
|
|
# Create the WSGI application
|
|
application = app
|
|
|
|
if __name__ == '__main__':
|
|
# This is only for development/testing
|
|
# In production, use: gunicorn wsgi:application
|
|
print("Warning: Running WSGI directly. Use a proper WSGI server in production!")
|
|
application.run(host='0.0.0.0', port=5005) |