Gunicorn runs a Python web application on a production server. Use its virtual-environment executable and absolute paths to make deployment more repeatable and avoid system-wide package conflicts. section 3.4.1
Run the FastAPI application
From the server, start Gunicorn with a Uvicorn worker, point it at the application directory, expose port 8888, and record its process ID: /opt/venv/bin/gunicorn \ --worker-class uvicorn.workers.UvicornWorker \ --chdir /opt/projects/roadtok8s/py/src/ \ main:app \ --bind "0.0.0.0:8888" \ --pid /var/run/roadtok8s-py.pid section 3.4.1
Listing 3.20 Command to run the Python application
/opt/venv/bin/gunicorn \
--worker-class uvicorn.workers.UvicornWorker \
--chdir /opt/projects/roadtok8s/py/src/ \
main:app \
--bind "0.0.0.0:8888" \
--pid /var/run/roadtok8s-py.pid
Inspect the complete startup command and its worker, application path, bind address, and PID-file options. section 3.4.1
