Files
team-tryouts/wsgi.py
T
GGThed 47ff544848 chore(lint): trier les imports, sauf la facade des modeles
Active la regle isort (I) de ruff. 45 fichiers reordonnes, aucun
changement de comportement : la suite passe avant comme apres.

app/models/__init__.py en est exclu. Ses imports sont ranges en onze
couches commentees qui decrivent le graphe de dependances ; trier par
ordre alphabetique laisse chaque titre au-dessus d un import qu il ne
decrit pas, et ce fichier n a qu un role, etre lu.

Commit isole, comme le formatage : un diff de brassage ne doit pas
servir de couverture a un changement de comportement.
2026-08-11 11:40:41 -04:00

44 lines
1.3 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 multiprocessing
import os
from app.app import create_app
app = create_app()
if __name__ == '__main__':
from waitress import serve
port = int(os.getenv('PORT', 10000))
threads = int(os.getenv('WAITRESS_THREADS', multiprocessing.cpu_count() * 2 + 1))
host = os.getenv('HOST', '0.0.0.0') # 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,
# Waitress Proxy Settings
trusted_proxy='*',
trusted_proxy_count=1,
trusted_proxy_headers={'x-forwarded-for', 'x-forwarded-proto'},
clear_untrusted_proxy_headers=True,
)