Git Product home page Git Product logo

django-probes's Introduction

Django-probes Latest version on PyPI

Build status Python versions Software 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.

Installation

The easiest way to install django-probes is with pip

$ pip install django-probes

Basic Usage

  1. Add django-probes to your Django application:
INSTALLED_APPS = [
    ...
    'django_probes',
]

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

- 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']

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

django-probes's People

Contributors

basharsaid avatar bittner avatar jor-rit avatar simingy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.