37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
"""WSGI entry point for the Team Tryouts application.
|
|
|
|
This module provides the production WSGI server using Waitress (Windows).
|
|
Use this file to start the application in production instead of Flask's
|
|
built-in development server.
|
|
|
|
Usage:
|
|
python wsgi.py
|
|
|
|
Configuration via environment variables:
|
|
PORT: Port to listen on (default: 5000)
|
|
WAITRESS_THREADS: Number of worker threads (default: CPU*2+1)
|
|
"""
|
|
|
|
import os
|
|
import multiprocessing
|
|
from app.app import create_app
|
|
|
|
app = create_app()
|
|
|
|
if __name__ == '__main__':
|
|
from waitress import serve
|
|
|
|
port = int(os.getenv('PORT', 5000))
|
|
threads = int(os.getenv('WAITRESS_THREADS', multiprocessing.cpu_count() * 2 + 1))
|
|
host = os.getenv('HOST', '127.0.0.1') # Bind to localhost by default (Nginx reverse proxy)
|
|
|
|
print(f'Starting Waitress server on {host}:{port} with {threads} threads')
|
|
serve(
|
|
app,
|
|
host=host,
|
|
port=port,
|
|
threads=threads,
|
|
# Graceful shutdown settings
|
|
channel_timeout=30, # Seconds to wait for in-flight requests
|
|
cleanup_interval=30,
|
|
) |