Welcome to Django Downtime!

Overview

Small, simple, app to show a down page while you make upgrades.

Purpose

This app simply runs middleware that checks to see if the site is down for maintenance. If it is, (with a period of downtime added to the apps models) either a redirect occurs or a template is loaded with a down time message. This app isn’t intended to be a full service solution as it still requires that the django site remain functional to work. In other cases it may be more beneficial to point your domain at a different server instead.

Contents:

Installation

Django Downtime supports Django 1.8 - 1.9 and Python 2 and 3.

To install django-downtime:

pip install django-downtime

add to installed apps:

INSTALLED_APPS += (
    'downtime',
)

Add downtime middleware to the top your list of installed middlewares:

'downtime.middleware.DowntimeMiddleware',

Settings

Exempted URLs:

DOWNTIME_EXEMPT_EXACT_URLS = (
    '/', # exempts homepage
    '/other_location/not_down/page',
)

Exempted Paths:

DOWNTIME_EXEMPT_PATHS = (
    '/admin',
    '/other_location_not_down',
)

Url Redirect:

DOWNTIME_URL_REDIRECT = "http://errors.mypage.com"

Templates

If no URL Redirect is specified a lame default template is rendered, this can be overridden by specifying a downtime/downtime.html template.

Usage

Adding Downtime

Using the admin site

Head on over to the django admin and add a new period instance. It is recommended to add your admin site to the tuple of DOWNTIME_EXEMPT_PATHS so that you can still login and bring the site online earlier than scheduled.

Using the management command

Use python manage.py downtime_start to start an unscheduled downtime. This sets a start date time and mark is as enabled. We call this “deployment mode”, usually called before running a deployment script.

Bringing The Site Back Up

Using the admin site

Either delete the Period instance or uncheck enable for the current downtime instance.

Using the management command

To set the site back up run python manage.py downtime_end.

This sets a end date time to all records that has a start date time and no end date time set and are marked as enabled. We call this “closing deployment mode”, usually called after running a deployment script.

Contributors

Authors

  • Derek Stegelman (dstegelman)

Contributors

  • Philippe O. Wagner (philippeowagner)
  • Martey Dodoo (martey)
  • bartoszgrabski
  • Harley Hauer (hhauer)
  • Thijs Triemstra (thijstriemstra)
  • Kevin Glover (kevinglover)
  • Peter J. Farrell (peterfarrell)
  • Aaron DeVore (adevore)

Changelog

1.1.2

  • Timezone updates

1.1.1

  • Django 1.10 support

1.1.0

  • Django 1.9 support
  • Drop support for below 1.8

1.0.4

  • Exempt specific URLs #33

1.0.3

  • Command bug fixes
  • Added date/time to unicode for models.

1.0.2

  • Add downtime up/down commands

1.0.1

  • Templates were not bundled correctly in 1.0.0

1.0.0

  • Python 2/3 Support. Django 1.8 support

0.3.3

  • Change status code to 503 #13

0.3.2

  • Minor changes to fix deprecation warnings in Django 1.7.

0.3.1

0.3

0.2

0.1

License

The MIT License (MIT)

Copyright (c) 2012 - 2017 Derek Stegelman

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.