Skip to content

Commit

Permalink
Merge pull request #105 from mwarkentin/custom-databases
Browse files Browse the repository at this point in the history
Allow overriding CACHES/DATABASES for watchman checks
  • Loading branch information
mwarkentin authored May 24, 2017
2 parents 03cf648 + 75d72ff commit e3d5e53
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
9 changes: 9 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
History
=======

0.13.0 (2017-05-23)
-------------------

* [`#105 <https://github.com/mwarkentin/django-watchman/pull/105>`_] Add ``WATCHMAN_CACHES`` and ``WATCHMAN_DATABASES`` settings to override the Django defaults

* When using watchman with a large number of databases, the default checks can cause an excess of connections to the database / cache
* New settings allow you to check only a subset of databases / caches
* Watchman will still default to checking all databases / caches, so no changes necessary for most apps

0.12.0 (2017-02-22)
-------------------

Expand Down
9 changes: 9 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ querystring should be run, eg::

curl -XGET http://127.0.0.1:8080/watchman/?skip=watchman.checks.email

Check a subset of databases or caches
*************************************

If your application has a large number of databases or caches configured,
watchman may open too many connections as it checks each database or cache.

You can set the ``WATCHMAN_DATABASES`` or ``WATCHMAN_CACHES`` settings in order
to override the default set of databases and caches to be monitored.

Django management command
*************************

Expand Down
2 changes: 1 addition & 1 deletion watchman/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.12.0'
__version__ = '0.13.0'
5 changes: 2 additions & 3 deletions watchman/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import unicode_literals

import uuid
from django.conf import settings
from django.core.files.base import ContentFile
from django.core.files.storage import default_storage
from django.core.mail import EmailMessage
Expand Down Expand Up @@ -68,11 +67,11 @@ def _check_storage():


def caches():
return {"caches": _check_caches(settings.CACHES)}
return {"caches": _check_caches(watchman_settings.WATCHMAN_CACHES)}


def databases():
return {"databases": _check_databases(settings.DATABASES)}
return {"databases": _check_databases(watchman_settings.WATCHMAN_DATABASES)}


def email():
Expand Down
3 changes: 3 additions & 0 deletions watchman/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
WATCHMAN_EMAIL_RECIPIENTS = getattr(settings, 'WATCHMAN_EMAIL_RECIPIENTS', ['[email protected]'])
WATCHMAN_EMAIL_HEADERS = getattr(settings, 'WATCHMAN_EMAIL_HEADERS', {})

WATCHMAN_CACHES = getattr(settings, 'WATCHMAN_CACHES', settings.CACHES)
WATCHMAN_DATABASES = getattr(settings, 'WATCHMAN_DATABASES', settings.DATABASES)

DEFAULT_CHECKS = (
'watchman.checks.caches',
'watchman.checks.databases',
Expand Down

0 comments on commit e3d5e53

Please sign in to comment.