Add uvloop

This commit is contained in:
itqop 2024-10-23 02:49:35 +03:00
parent 8a7134f727
commit 67dfbf2e7c
3 changed files with 12 additions and 1 deletions

View File

@ -14,4 +14,4 @@ RUN pip install torch --index-url https://download.pytorch.org/whl/cpu
EXPOSE 8002 EXPOSE 8002
CMD ["gunicorn", "app.main:app", "--worker-class", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8002", "--workers", "4", "--loop", "uvloop"] CMD ["gunicorn", "--worker-class", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8002", "--workers", "4"]

View File

@ -7,6 +7,7 @@ from fastapi.middleware.cors import CORSMiddleware
from app.api import routes from app.api import routes
from app.core.config import settings from app.core.config import settings
from app.core.cache import cache from app.core.cache import cache
import uvicorn
# Настройка логирования # Настройка логирования
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
@ -46,3 +47,12 @@ async def global_exception_handler(request: Request, exc: Exception):
status_code=500, status_code=500,
content={"detail": "Внутренняя ошибка сервера."}, content={"detail": "Внутренняя ошибка сервера."},
) )
if __name__ == "__main__":
uvicorn.run(
"app.main:app",
host="0.0.0.0",
port=8082,
loop="uvloop"
)

View File

@ -1,5 +1,6 @@
fastapi fastapi
uvicorn[standard] uvicorn[standard]
uvloop
transformers transformers
gunicorn gunicorn
redis>=4.0 redis>=4.0