Skip to main content

A management command to start production servers/workers with a consistent interface

Project description

Django prodserver

CI Status Documentation Status Test coverage percentage

uv Ruff pre-commit

PyPI Version Supported Python versions License


Documentation: https://django-prodserver.readthedocs.io

Source Code: https://github.com/nanorepublica/django-prodserver


A management command to start production servers/workers with a consistent interface

Installation

Install this via pip (or your favourite package manager):

pip install django-prodserver

Add the app to your INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    "django_prodserver",
]

Configuration

Add the PRODUCTION_PROCESSES setting to your settings.py. Below shows an example with a web process and worker process defined.

The comments show other available backend processes that are available to use.

PRODUCTION_PROCESSES = {
    "web": {
        "BACKEND": "django_prodserver.backends.gunicorn.GunicornServer",
        "ARGS": {"bind": "0.0.0.0:8111"},
    },
    # "web": {
    #     "BACKEND": "django_prodserver.backends.granian.GranianASGIServer",
    #     "ARGS": {"address": "0.0.0.0", "port": "8000", "workers": "4"},
    # },
    # "web": {
    #     "BACKEND": "django_prodserver.backends.granian.GranianWSGIServer",
    #     "ARGS": {"address": "0.0.0.0", "port": "8000", "workers": "4"},
    # },
    # "web": {
    #     "BACKEND": "django_prodserver.backends.waitress.WaitressServer",
    #     "ARGS": {},
    # },
    # "web": {
    #     "BACKEND": "django_prodserver.backends.uvicorn.UvicornServer",
    #     "ARGS": {},
    # },
    # "web": {
    #     "BACKEND": "django_prodserver.backends.uvicorn.UvicornWSGIServer",
    #     "ARGS": {},
    # },
    "worker": {
        "BACKEND": "django_prodserver.backends.celery.CeleryWorker",
        "APP": "tests.celery.app",
        "ARGS": {},
    },
    # "worker": {
    #     "BACKEND": "django_prodserver.backends.django_tasks.DjangoTasksWorker",
    #     "ARGS": {},
    # },
}

Usage

Once the PRODUCTION_PROCESSES setting has been configured you can then start the processes as follows:

python manage.py prodserver web
python manage.py prodserver worker

Creating a new backend.

Creating a backend is fairly simple. Subclass the BaseServerBackend class, then implement the start_server method which should call the underlying process in the best possible way for a production setting. You can also optionally override prep_server_args method to aid with this to provide any default arguments or formatting to the start_server command.

See django_prodserver.backends for examples of existing backends for inspiration. Pull Request's are welcome for additional backends.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

Credits

Copier

This package was created with Copier and the browniebroke/pypackage-template project template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_prodserver-2.3.0.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_prodserver-2.3.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file django_prodserver-2.3.0.tar.gz.

File metadata

  • Download URL: django_prodserver-2.3.0.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_prodserver-2.3.0.tar.gz
Algorithm Hash digest
SHA256 50426df3fe3a0bf066eaba9c32bfc6d66d3d86dbabc348c926ac6c7e3b5d4935
MD5 0df74eb97d2bb36652c8ad773d303e52
BLAKE2b-256 11253c353b3fc461f782cae335d29a0f11ecb2682110b31dea3fc34d57ddf767

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_prodserver-2.3.0.tar.gz:

Publisher: ci.yml on nanorepublica/django-prodserver

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_prodserver-2.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_prodserver-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0dbf290bc45e0e1318235d5a72e54f876dc7f5dd6e017833d021d0b0f9f3ef58
MD5 8fc427709b3820c66cd032d82bc0ca15
BLAKE2b-256 fe7d060350f6bbc1f272b735a4d2dde3faecb737162eec8c0e985918bca0427b

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_prodserver-2.3.0-py3-none-any.whl:

Publisher: ci.yml on nanorepublica/django-prodserver

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page