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
Install this via pip (or your favourite package manager):
pip install django-prodserver
Add the app to your INSTALLED_APPS
:
INSTALLED_APPS = [
# ...
"django_prodserver",
]
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.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": {},
# },
}
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 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.
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
This package was created with Copier and the browniebroke/pypackage-template project template.