liveBook · Manning

Gunicorn

As explained in Road to Kubernetes

Gunicorn is a Python WSGI HTTP server for running web applications in production.

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

How Road to Kubernetes covers it

How deep it goes
Shows the executable path and a runnable command with worker, directory, binding, and PID options.
Examples
Uses /opt/venv/bin/gunicorn to serve main:app on 0.0.0.0:8888 with a Uvicorn worker.
What it assumes
Assumes Linux, Python 3, a virtual environment, installed dependencies, and a checked-out application directory.
What you can do after
Operate/configure Gunicorn to launch the application with explicit paths, worker selection, network binding, and PID tracking.
How it connects
Connects Gunicorn with Python virtual environments, FastAPI, Uvicorn workers, Git hooks, and absolute paths.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Road to Kubernetes. The section links point to the parts of the book it draws on.