django와 유비콘 사용방법

Uvicorn은 속도를 중시하는 “uvloop”과 “http tools”에 기반을 둔 ASGI 서버이다.

Uvicorn 설치

“pip”로 Uvicorn을 설치할 수 있다.

python -m pip install uvicorn

Uvicorn에서 django 실행

Uvicorn이 설치되면 ASGI 애플리케이션을 실행하는 “uvicorn” 명령을 사용할 수 있다. Uvicorn은 ASGI 애플리케이션 개체가 포함된 모듈의 위치로 호출되어야 하며 그 다음에 애플리케이션 이름이 콜론으로 구분됩니다.

일반적인 Django 프로젝트의 경우 Uvicorn을 호출하는 방법은 다음과 같습니다.

python -m uvicorn myproject.asgi:application

이로써 “127.0.0.1:8000”에 대한 청취가 시작된다. 프로젝트가 Python 경로에 있어야 합니다. ``관리”와 동일한 디렉토리에서 이 명령을 실행해야 합니다.

In development mode, you can add --reload to cause the server to reload any time a file is changed on disk.

고급 사용법은 Uvicorn document를 읽어주세요.

Deploying Django using Uvicorn and Gunicorn

Gunicorn is a robust web server that implements process monitoring and automatic restarts. This can be useful when running Uvicorn in a production environment.

To install Uvicorn and Gunicorn, use the following:

python -m pip install uvicorn gunicorn

Then start Gunicorn using the Uvicorn worker class like this:

python -m gunicorn myproject.asgi:application -k uvicorn.workers.UvicornWorker