Git Product home page Git Product logo

django-heartbeat's Introduction

A simple django app that responds to heartbeat polls.

In a cluster of load-balanced web servers, this allows you to take a server out of service gracefully, by letting your load balancer know that the server is going down before shutting down.

To implement, add 'heartbeat' to INSTALLED_APPS in your Django settings file.

A control file is used for signalling. Use the following setting in your Django settings file to specify the path for the control file:

HEARTBEAT_FILENAME = '/etc/heartbeat'

If this file exists and contains a 0, heartbeat will respond with a 503 to let a load balancer know to stop sending new requests to the server because the server is going down for maintenance.

To set, use eg:

$ echo 0 > etc/heartbeat

Or you can use the Django management commands:

$ bin/django heartbeat down
$ bin/django heartbeat up

Used with HAProxy, your HAProxy config file might contain this:

backend site
    balance roundrobin
    option httpchk HEAD /heartbeat/status/ HTTP/1.0
    option httpclose
    server web-appserver-A-1 10.0.2.2:80 check inter 5000
    server web-appserver-A-2 10.0.2.3:80 check inter 5000
    server web-appserver-A-3 10.0.2.4:80 check inter 5000
    server web-appserver-B-1 10.0.5.2:80 check inter 5000
    server web-appserver-B-2 10.0.5.3:80 check inter 5000
    server web-appserver-B-3 10.0.5.4:80 check inter 5000

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.