{ "info": { "author": "Peter Baumgartner", "author_email": "pete@lincolnloop.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# django-webserver\n\nRun production webservers such as [pyuwsgi](https://pypi.org/project/pyuwsgi/) (aka uWSGI) or [gunicorn](https://pypi.org/project/gunicorn/) as a Django management command.\n\n----\n\n[![build status](https://travis-ci.org/lincolnloop/django-webserver.svg?branch=master)](https://travis-ci.org/lincolnloop/django-pyuwsgi) [![pypi](https://img.shields.io/pypi/v/django-webserver.svg)](https://pypi.org/pypi/django-webserver) [![pyversions](https://img.shields.io/pypi/pyversions/django-webserver.svg)](https://pypi.org/pypi/django-webserver)\n\n## Usage\n\n1. Install a variant:\n\n ```\n pip install django-webserver[pyuwsgi]\n ```\n\n or\n\n ```\n pip install django-webserver[gunicorn]\n ```\n\n or\n\n ```\n pip install django-webserver[uvicorn] # Python 3.5+ only\n ```\n\n or\n\n ```\n pip install django-webserver[waitress]\n ```\n\n2. Add to `INSTALLED_APPS`:\n\n ```python\n INSTALLED_APPS = [\n # ...\n \"django_webserver\",\n # ...\n ]\n ```\n3. Run:\n\n ```\n manage.py pyuwsgi --http=:8000 ...\n ```\n\n or\n\n ```\n manage.py gunicorn\n ```\n\n or\n\n ```\n manage.py uvicorn\n ```\n\n or\n\n ```\n manage.py waitress --port=8000\n ```\n\n## Configuration\n\n### With pyuwsgi\n\n![uwsgi logo](https://cldup.com/uiFb8Sn4Ea.png)\n\n[(py)uWSGI docs](https://uwsgi-docs.readthedocs.io/en/latest/)\n\nPyuwsgi already knows the Python interpreter and virtualenv (if applicable) to use from the Django management command environment. By default, it will run with the following flags (using `settings.WSGI_APPLICATION` to determine the module):\n\n```\n--strict --need-app --module={derived}\n```\n\nIf you have `STATIC_URL` defined with a local URL, it will also add `--static-map`, derived from `STATIC_URL` and `STATIC_ROOT`.\n\nYou can pass any additional arguments uWSGI accepts in from the command line.\n\nBut uWSGI has a lot of flags, and many of them, you want every time you run the project. For that scenario, you can configure your own defaults using the optional setting, `PYUWSGI_ARGS`. Here's an example you might find helpful:\n\n```python\nPYUWSGI_ARGS = [\n \"--master\",\n \"--strict\",\n \"--need-app\",\n \"--module\".\n \":\".join(WSGI_APPLICATION.rsplit(\".\", 1)),\n \"--no-orphans\",\n \"--vacuum\",\n \"--auto-procname\",\n \"--enable-threads\",\n \"--offload-threads=4\",\n \"--thunder-lock\",\n \"--static-map\",\n \"=\".join([STATIC_URL.rstrip(\"/\"), STATIC_ROOT]),\n \"--static-expires\",\n \"/* 7776000\",\n]\n```\n\nDon't forget to also set something like `--socket=:8000` or `--http=:8000` so your app listens on a port. Depending on your setup, it may make more sense to pass this in via the command line than hard-coding it in your settings.\n\n### With gunicorn\n\n![gunicorn logo](https://cldup.com/TObFsJSacv.png)\n\n[gunicorn docs](https://docs.gunicorn.org/en/stable/)\n\nSame as the standard gunicorn configuration, but the application will be set for you from `settings.WSGI_APPLICATION`.\n\n_Note: Unlike the other servers, you have to configure gunicorn with environment variables or via `sys.argv`. If you use it with Django's `call_command`, keep in mind any additional arguments you pass will not be applied._\n\n### With uvicorn\n\n![uvicorn logo](https://cldup.com/By389I7ZHd.png)\n\n[uvicorn docs](https://www.uvicorn.org/)\n\nSame as the standard uvicorn configuration, but the application will be set for you from `settings.WSGI_APPLICATION` as well as `--wsgi`.\n\n### With waitress\n\n![waitress logo](https://cldup.com/3m18XSyzuM.png)\n\n[waitress docs](https://docs.pylonsproject.org/projects/waitress/en/latest/index.html)\n\nSame as the standard [`waitress-serve`](https://docs.pylonsproject.org/projects/waitress/en/latest/runner.html) arguments, but the application will be set for you from `settings.WSGI_APPLICATION`.\n\nUnlike the other servers, waitress is supported on Windows.\n\n### Pre-warming Your App\n\nDefault:\n\n```python\nWEBSERVER_WARMUP = True\n```\n\nTypically, when a WSGI server starts, it will bind to the necessary ports _then_ import/setup your application. On larger projects, it's normal for startup to take multiple seconds. During that time, it is unable to respond to incoming requests.\n\nTo avoid that downtime, this app imports your WSGI module _before_ starting the relevant server. If, for some reason this behavior is undesirable, you can set `WEBSERVER_WARMUP = False` in your settings.\n\n### Running a Healthcheck at Startup\n\nThis is not enabled by default. It requires `WEBSERVER_WARMUP = True`.\n\n```python\nWEBSERVER_WARMUP_HEALTHCHECK = \"/-/health/\"\n```\n\nInternally calls the provided URL prior to starting the server and exits with a failure if it does not return a `200`.\n\nIt can be helpful to have your app exit immediately if it is unable to successfully respond to a healthcheck. Your process or container manager should immediately show the service failed instead of waiting for a load balancer or some other monitoring tool to notify catch the problem.\n\n\n## Motivation\n\nIn some scenarios, it is beneficial to distribute a Django project with a single entrypoint for command-line interaction. This can come in handy when building Docker containers or self-contained Python apps with something like [shiv](https://github.com/linkedin/shiv).\n\nPre-warming the application and running a healthcheck can also open the door for some zero-downtime deployment scenarios that previously weren't possible due to the issues described in \"Pre-warming your app\". For example, you could use the `--reuse-port` option in uWSGI or gunicorn to bring up a new version of your app on the same port, knowing it is already warmed-up and healthy. After a successful startup, the old version can safely be torn down without dropping any traffic.\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/lincolnloop/django-webserver", "keywords": "django webserver pyuwsgi uwsgi gunicorn waitress WSGI HTTP", "license": "", "maintainer": "", "maintainer_email": "", "name": "django-webserver", "package_url": "https://pypi.org/project/django-webserver/", "platform": "", "project_url": "https://pypi.org/project/django-webserver/", "project_urls": { "Homepage": "https://github.com/lincolnloop/django-webserver" }, "release_url": "https://pypi.org/project/django-webserver/1.1.0/", "requires_dist": [ "Django", "pytest; extra == \"test\"", "mock; extra == \"test\" and ( python_version < '3.3')", "pyuwsgi; extra == \"pyuwsgi\"", "gunicorn; extra == \"gunicorn\"", "uvicorn; extra == \"uvicorn\" and ( python_version >= '3.5')", "waitress; extra == \"waitress\"" ], "requires_python": "", "summary": "Django management commands for production webservers", "version": "1.1.0" }, "last_serial": 4438767, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "4e66b98a0d6f65c3042dcd69313c1baa", "sha256": "c63be277759ed71a2db8f99c3c26a8c86c663b5505950ff19e22c1b2a484dd17" }, "downloads": -1, "filename": "django_webserver-1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "4e66b98a0d6f65c3042dcd69313c1baa", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": "~=2.7,>=3.5", "size": 14942, "upload_time": "2018-10-20T03:15:30", "url": "https://files.pythonhosted.org/packages/83/32/2b466d90b24243c2967121c45d2b19545433d435a434c86c99ef5499dd26/django_webserver-1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4608b7c60d9cc3d9e98caf003dd0df08", "sha256": "de6c0c59f2b373f6dc93f48c7828ac83ba489caf684f25335203ddba27cbfb18" }, "downloads": -1, "filename": "django-webserver-1.0.tar.gz", "has_sig": false, "md5_digest": "4608b7c60d9cc3d9e98caf003dd0df08", "packagetype": "sdist", "python_version": "source", "requires_python": "~=2.7,>=3.5", "size": 7124, "upload_time": "2018-10-20T03:15:34", "url": "https://files.pythonhosted.org/packages/e4/ba/bc2266513d78f5c2416382d118467a0bd5d46970a047aa71a54d4895d92a/django-webserver-1.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "76f4f3237fb0f0b5324a1f5cf9e4ffc7", "sha256": "e2269cc66017ef64640fe12e84bd3db9fb14a5122c3c84306674e853a0239a85" }, "downloads": -1, "filename": "django_webserver-1.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "76f4f3237fb0f0b5324a1f5cf9e4ffc7", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 14956, "upload_time": "2018-10-20T04:32:47", "url": "https://files.pythonhosted.org/packages/b9/6a/e7304cdfac8bdd512e7f1375660c2acfc8d4438c6dc1f87d4bf077767bd1/django_webserver-1.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f24f4f16a54cad88e9b8c14318f7bafe", "sha256": "83e1018fb5dee632e418f55f9d326ae939c9591b7389d07e89655d44456304ba" }, "downloads": -1, "filename": "django-webserver-1.0.1.tar.gz", "has_sig": false, "md5_digest": "f24f4f16a54cad88e9b8c14318f7bafe", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7170, "upload_time": "2018-10-20T04:32:52", "url": "https://files.pythonhosted.org/packages/cc/77/e770ba5031b8ee72029c831e8515a7d6b65af703ef37f7db964bf704b805/django-webserver-1.0.1.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "b37572b94c9c33a8eab8cd5d6473057a", "sha256": "1dd0d05ebb85581e8e7b5892243e795571a704cb58a71092442eef05fa01a973" }, "downloads": -1, "filename": "django_webserver-1.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b37572b94c9c33a8eab8cd5d6473057a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 16247, "upload_time": "2018-10-31T22:57:13", "url": "https://files.pythonhosted.org/packages/63/87/16f930e06d3934d947abdf5939c725c4e2a8569306b89c1c309f6811984d/django_webserver-1.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fd977264996201a8818201bea1766a80", "sha256": "5e3389592a1fbc4cbf0ce3d79696bcb9a9aef36783b850d616e4059dde7d71a1" }, "downloads": -1, "filename": "django-webserver-1.1.0.tar.gz", "has_sig": false, "md5_digest": "fd977264996201a8818201bea1766a80", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7713, "upload_time": "2018-10-31T22:57:19", "url": "https://files.pythonhosted.org/packages/43/cd/21f5528d12a5af30cc8d20289b306c2c8842b4345cf0522fd03d3a932bce/django-webserver-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b37572b94c9c33a8eab8cd5d6473057a", "sha256": "1dd0d05ebb85581e8e7b5892243e795571a704cb58a71092442eef05fa01a973" }, "downloads": -1, "filename": "django_webserver-1.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b37572b94c9c33a8eab8cd5d6473057a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 16247, "upload_time": "2018-10-31T22:57:13", "url": "https://files.pythonhosted.org/packages/63/87/16f930e06d3934d947abdf5939c725c4e2a8569306b89c1c309f6811984d/django_webserver-1.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fd977264996201a8818201bea1766a80", "sha256": "5e3389592a1fbc4cbf0ce3d79696bcb9a9aef36783b850d616e4059dde7d71a1" }, "downloads": -1, "filename": "django-webserver-1.1.0.tar.gz", "has_sig": false, "md5_digest": "fd977264996201a8818201bea1766a80", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7713, "upload_time": "2018-10-31T22:57:19", "url": "https://files.pythonhosted.org/packages/43/cd/21f5528d12a5af30cc8d20289b306c2c8842b4345cf0522fd03d3a932bce/django-webserver-1.1.0.tar.gz" } ] }