| import asyncio | |
| import logging | |
| import sys | |
| import uvicorn | |
| logging.basicConfig( | |
| level=logging.INFO, | |
| format="%(asctime)s [%(levelname)s] %(name)s: %(message)s", | |
| datefmt="%Y-%m-%d %H:%M:%S", | |
| ) | |
| logger = logging.getLogger("s3shastra.server") | |
| if __name__ == "__main__": | |
| # Force ProactorEventLoop on Windows to avoid "too many file descriptors" error | |
| if sys.platform == "win32": | |
| asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy()) | |
| logger.info("Windows detected: Forcing WindowsProactorEventLoopPolicy") | |
| logger.info("Starting S3Shastra Backend...") | |
| try: | |
| uvicorn.run( | |
| "main:app", | |
| host="0.0.0.0", | |
| port=8000, | |
| reload=False, | |
| loop="asyncio", | |
| log_level="info", | |
| timeout_keep_alive=30, | |
| limit_concurrency=100, | |
| limit_max_requests=10000, | |
| ) | |
| except Exception as e: | |
| logger.error("Server failed to start: %s", e) | |