Configuration

django-prodserver is configured through the PRODUCTION_PROCESSES setting.

Basic Structure

PRODUCTION_PROCESSES = {
    "process_name": {
        "BACKEND": "path.to.backend.class",
        "APP": "optional.app.path",  # Required for Celery
        "ARGS": {"arg_name": "value"},
    }
}

Configuration Keys

BACKEND (Required)

Python import path to the backend class:

"BACKEND": "django_prodserver.backends.servers.gunicorn.GunicornServer"

Available backends:

APP (Celery only)

Path to Celery app instance:

"APP": "myproject.celery.app"

ARGS

Arguments passed to the backend, converted to CLI flags:

"ARGS": {
    "bind": "0.0.0.0:8000",      # --bind=0.0.0.0:8000
    "workers": "4",               # --workers=4
}

How ARGS Translation Works:

  1. Dictionary keys become argument names (with -- prefix)

  2. Dictionary values become argument values (with = separator)

  3. Arguments are passed directly to the underlying backend

Example Translation:

# Settings configuration
PRODUCTION_PROCESSES = {
    "web": {
        "BACKEND": "django_prodserver.backends.servers.gunicorn.GunicornServer",
        "ARGS": {
            "bind": "0.0.0.0:8000",
            "workers": "4",
            "worker-class": "sync",
            "timeout": "60"
        }
    }
}

# Translates to CLI command:
# gunicorn --bind=0.0.0.0:8000 --workers=4 --worker-class=sync --timeout=60

See Backend Reference for backend-specific ARGS.

Complete Configuration Examples

Single Web Server

Basic Gunicorn web server:

PRODUCTION_PROCESSES = {
    "web": {
        "BACKEND": "django_prodserver.backends.servers.gunicorn.GunicornServer",
        "ARGS": {"bind": "0.0.0.0:8000", "workers": "4"},
    }
}

Web + Worker + Beat

PRODUCTION_PROCESSES = {
    "web": {
        "BACKEND": "django_prodserver.backends.servers.gunicorn.GunicornServer",
        "ARGS": {"bind": "0.0.0.0:8000", "workers": "4"},
    },
    "worker": {
        "BACKEND": "django_prodserver.backends.workers.celery.CeleryWorker",
        "APP": "myproject.celery.app",
        "ARGS": {"concurrency": "4", "loglevel": "info"},
    },
    "beat": {
        "BACKEND": "django_prodserver.backends.workers.celery.CeleryBeat",
        "APP": "myproject.celery.app",
        "ARGS": {"loglevel": "info"},
    },
}

Environment Variables

import os

PRODUCTION_PROCESSES = {
    "web": {
        "BACKEND": "django_prodserver.backends.servers.gunicorn.GunicornServer",
        "ARGS": {
            "bind": f"0.0.0.0:{os.getenv('PORT', '8000')}",
            "workers": os.getenv('WEB_WORKERS', '4'),
        },
    }
}

Best Practices

  1. Use environment-specific settings files (settings_dev.py, settings_prod.py)

  2. Use environment variables for deployment-specific values

  3. Start with workers = CPU_count * 2 + 1 and tune based on monitoring

  4. Set appropriate timeouts for your application

  5. Use process supervision (systemd, Docker) for automatic restarts

Common Mistakes

Warning

  • Port conflicts: Each process needs a unique port

  • Missing APP: Celery backends require the APP key

  • Wrong BACKEND path: Use full import path including class name

  • Missing backend package: Install gunicorn, celery, etc.

API Documentation

These are the available settings.

All attributes prefixed PRODUCTION_* can be overridden from your Django project’s settings module by defining a setting with the same name.

class django_prodserver.conf.AppSettings[source]

Access this instance as .conf.app_settings.

PRODUCTION_PROCESSES: Mapping[str, Mapping[str, str]]

Whether the app is enabled (dummy setting to demo usage).

Next Steps