yola / healthcheck

Classes, which help Yola service to implement health checks for themselves

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HealthCheck

Build Status Coverage Status

Classes and Django apps, which help Yola services do health checks.

Using the library directly:

from healthcheck import (
    HealthChecker, DjangoDBsHealthCheck, FilesDontExistHealthCheck)


class StatusView(View):

    checks = [
        DjangoDBsHealthCheck(),
        FilesDontExistHealthCheck(
            ('/etc/yola/quiesce',), check_id='quiesce file doesn\'t exist'),]

    def get(self, *args, **kwargs):
        ok, details = HealthChecker(self.checks)()

        if not ok:
            return HttpResponseServerError((json.dumps(details)))

        return HttpResponse(json.dumps(details))

As a result, URL handled by this view will return data like this:

{
    "Django Databases Health Check":
        {
            "status": "ok",
            "details": {
                            "default": "ok",
                            "usersites2": "ok",
                            "usersites1": "ok"
            }
          },

    "quiesce file doesn't exist":
        {
            "status": "ok",
            "details": {
                            "/etc/yola/quiesce": "no such file"
            }
        }
}

Using the Django app:

  1. Add 'status' to your INSTALLED_APPS setting like this:
    INSTALLED_APPS = (
        ...
        'healthcheck.contrib.django.status_endpoint',
    )
  1. Include the status_endpoint URLconf in your project urls.py like this:
    url(r'^status/', include('healthcheck.contrib.django.status_endpoint.urls'))
  1. Visit http://127.0.0.1:8000/status/ to see the output of the healthchecks.
{
    "Django Databases Health Check":
        {
            "status": "ok",
            "details": {
                "default": "ok",
                "usersites2": "ok",
                "usersites1": "ok"
            }
          },
    "quiesce file doesn't exist":
        {
            "status": "ok",
            "details": {
                "/etc/yola/quiesce": "no such file"
            }
        }
}

Running Tests

cd healthcheck; python setup.py test

About

Classes, which help Yola service to implement health checks for themselves

License:MIT License


Languages

Language:Python 100.0%