django-probes


Namedjango-probes JSON
Version 1.7.0 PyPI version JSON
download
home_pagehttps://github.com/painless-software/django-probes
SummaryMake Django wait until database is ready. Probes for Docker and Kubernetes.
upload_time2022-08-11 20:23:14
maintainer
docs_urlNone
authorPeter Bittner
requires_python
license
keywords django database probes docker kubernetes
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Django-probes |latest-version|
==============================

|checks-status| |tests-status| |python-support| |license|

Provides a Django management command to check whether the primary database
is ready to accept connections.

Run this command in a Kubernetes or OpenShift `Init Container`_ to make
your Django application wait until the database is available (e.g. to run
database migrations).

Why Should I Use This App?
--------------------------

``wait_for_database`` is a *single* command for *all* database engines
Django supports. It automatically checks the database you have configured
in your Django project settings. No need to code a specific wait command
for Postgres, MariaDB, Oracle, etc., no need to pull a database engine
specific container just for running the database readiness check.

.. |latest-version| image:: https://img.shields.io/pypi/v/django-probes.svg
   :alt: Latest version on PyPI
   :target: https://pypi.org/project/django-probes
.. |checks-status| image:: https://img.shields.io/github/workflow/status/painless-software/django-probes/Checks/main?label=Checks&logo=github
   :alt: GitHub Workflow Status
   :target: https://github.com/painless-software/django-probes/actions/workflows/check.yml
.. |tests-status| image:: https://img.shields.io/github/workflow/status/painless-software/django-probes/Tests/main?label=Tests&logo=github
   :alt: GitHub Workflow Status
   :target: https://github.com/painless-software/django-probes/actions/workflows/test.yml
.. |python-support| image:: https://img.shields.io/pypi/pyversions/django-probes.svg
   :alt: Python versions
   :target: https://pypi.org/project/django-probes
.. |license| image:: https://img.shields.io/pypi/l/django-probes.svg
   :alt: Software license
   :target: https://github.com/painless-software/django-probes/blob/main/LICENSE

.. _Init Container: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/

Installation
============

The easiest way to install django-probes is with pip

.. code:: console

    $ pip install django-probes

Basic Usage
===========

1. Add django-probes to your Django application:

.. code:: python

    INSTALLED_APPS = [
        ...
        'django_probes',
    ]

2. Add an `Init Container`_ to your Kubernetes/OpenShift deployment
configuration, which calls the ``wait_for_database`` management command:

.. code:: yaml

    - kind: Deployment
      apiVersion: apps/v1
      spec:
        template:
          spec:
            initContainers:
            - name: wait-for-database
              image: my-django-app:latest
              envFrom:
              - secretRef:
                  name: django
              command: ['python', 'manage.py', 'wait_for_database']

Use with Your Own Command
-------------------------

Alternatively, you can integrate the ``wait_for_database`` command in your
own management command, and do things like database migration, load initial
data, etc. with roughly the same Kubernetes setup as above.

.. code:: python

    from django.core.management import call_command

    # ...
    call_command('wait_for_database')

Command Line Options
--------------------

The management command comes with sane defaults, which you can override
if needed:

:--timeout, -t:
    how long to wait for the database before timing out (seconds), default: ``180``
:--stable, -s:
    how long to observe whether connection is stable (seconds), default: ``5``
:--wait-when-down, -d:
    delay between checks when database is down (seconds), default: ``2``
:--wait-when-alive, -a:
    delay between checks when database is up (seconds), default: ``1``
:--database:
    which database of ``settings.DATABASES`` to wait for, default: ``default``

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/painless-software/django-probes",
    "name": "django-probes",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django,database,probes,docker,kubernetes",
    "author": "Peter Bittner",
    "author_email": "django@bittner.it",
    "download_url": "https://files.pythonhosted.org/packages/3b/10/0d633eb9949ea3d6d87ee3056af6e4be48a9cdf1303ea3d66b5afa69c85b/django_probes-1.7.0.tar.gz",
    "platform": null,
    "description": "Django-probes |latest-version|\n==============================\n\n|checks-status| |tests-status| |python-support| |license|\n\nProvides a Django management command to check whether the primary database\nis ready to accept connections.\n\nRun this command in a Kubernetes or OpenShift `Init Container`_ to make\nyour Django application wait until the database is available (e.g. to run\ndatabase migrations).\n\nWhy Should I Use This App?\n--------------------------\n\n``wait_for_database`` is a *single* command for *all* database engines\nDjango supports. It automatically checks the database you have configured\nin your Django project settings. No need to code a specific wait command\nfor Postgres, MariaDB, Oracle, etc., no need to pull a database engine\nspecific container just for running the database readiness check.\n\n.. |latest-version| image:: https://img.shields.io/pypi/v/django-probes.svg\n   :alt: Latest version on PyPI\n   :target: https://pypi.org/project/django-probes\n.. |checks-status| image:: https://img.shields.io/github/workflow/status/painless-software/django-probes/Checks/main?label=Checks&logo=github\n   :alt: GitHub Workflow Status\n   :target: https://github.com/painless-software/django-probes/actions/workflows/check.yml\n.. |tests-status| image:: https://img.shields.io/github/workflow/status/painless-software/django-probes/Tests/main?label=Tests&logo=github\n   :alt: GitHub Workflow Status\n   :target: https://github.com/painless-software/django-probes/actions/workflows/test.yml\n.. |python-support| image:: https://img.shields.io/pypi/pyversions/django-probes.svg\n   :alt: Python versions\n   :target: https://pypi.org/project/django-probes\n.. |license| image:: https://img.shields.io/pypi/l/django-probes.svg\n   :alt: Software license\n   :target: https://github.com/painless-software/django-probes/blob/main/LICENSE\n\n.. _Init Container: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/\n\nInstallation\n============\n\nThe easiest way to install django-probes is with pip\n\n.. code:: console\n\n    $ pip install django-probes\n\nBasic Usage\n===========\n\n1. Add django-probes to your Django application:\n\n.. code:: python\n\n    INSTALLED_APPS = [\n        ...\n        'django_probes',\n    ]\n\n2. Add an `Init Container`_ to your Kubernetes/OpenShift deployment\nconfiguration, which calls the ``wait_for_database`` management command:\n\n.. code:: yaml\n\n    - kind: Deployment\n      apiVersion: apps/v1\n      spec:\n        template:\n          spec:\n            initContainers:\n            - name: wait-for-database\n              image: my-django-app:latest\n              envFrom:\n              - secretRef:\n                  name: django\n              command: ['python', 'manage.py', 'wait_for_database']\n\nUse with Your Own Command\n-------------------------\n\nAlternatively, you can integrate the ``wait_for_database`` command in your\nown management command, and do things like database migration, load initial\ndata, etc. with roughly the same Kubernetes setup as above.\n\n.. code:: python\n\n    from django.core.management import call_command\n\n    # ...\n    call_command('wait_for_database')\n\nCommand Line Options\n--------------------\n\nThe management command comes with sane defaults, which you can override\nif needed:\n\n:--timeout, -t:\n    how long to wait for the database before timing out (seconds), default: ``180``\n:--stable, -s:\n    how long to observe whether connection is stable (seconds), default: ``5``\n:--wait-when-down, -d:\n    delay between checks when database is down (seconds), default: ``2``\n:--wait-when-alive, -a:\n    delay between checks when database is up (seconds), default: ``1``\n:--database:\n    which database of ``settings.DATABASES`` to wait for, default: ``default``\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Make Django wait until database is ready. Probes for Docker and Kubernetes.",
    "version": "1.7.0",
    "project_urls": {
        "Homepage": "https://github.com/painless-software/django-probes"
    },
    "split_keywords": [
        "django",
        "database",
        "probes",
        "docker",
        "kubernetes"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a6b9caaef098801959efc30002fbdb91fc65e9ab6fb59700cd04b77cf988f6fa",
                "md5": "cce90913a3ab7be33824bfdd0be23b54",
                "sha256": "60e656b83cbd0e290fca8263b256d7ebc42452f8c55a07044e56736f986c99a5"
            },
            "downloads": -1,
            "filename": "django_probes-1.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cce90913a3ab7be33824bfdd0be23b54",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5813,
            "upload_time": "2022-08-11T20:23:12",
            "upload_time_iso_8601": "2022-08-11T20:23:12.643706Z",
            "url": "https://files.pythonhosted.org/packages/a6/b9/caaef098801959efc30002fbdb91fc65e9ab6fb59700cd04b77cf988f6fa/django_probes-1.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3b100d633eb9949ea3d6d87ee3056af6e4be48a9cdf1303ea3d66b5afa69c85b",
                "md5": "65fd8d54bebb420ee1087e7e4d83586d",
                "sha256": "bb54c9db54f9c6aaadb032fcf77dfb6c6b17e597df1585d667cfe7491d2747d0"
            },
            "downloads": -1,
            "filename": "django_probes-1.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "65fd8d54bebb420ee1087e7e4d83586d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5473,
            "upload_time": "2022-08-11T20:23:14",
            "upload_time_iso_8601": "2022-08-11T20:23:14.338555Z",
            "url": "https://files.pythonhosted.org/packages/3b/10/0d633eb9949ea3d6d87ee3056af6e4be48a9cdf1303ea3d66b5afa69c85b/django_probes-1.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-08-11 20:23:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "painless-software",
    "github_project": "django-probes",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "django-probes"
}
        
Elapsed time: 0.39927s