Django Reusable app that uses Celery Inspect command to monitor workers/tasks via the Django REST Framework
Project description
# django-celery-inspect
Django reusable-app that uses Celery Inspect command to monitor workers via the [Django REST Framework](https://github.com/tomchristie/django-rest-framework).
The main idea is to be able to monitor celery workers from another external service or server via a REST API and figure out if they are running or not by using celery's own [Inspect API]
(http://docs.celeryproject.org/en/latest/userguide/workers.html#inspecting-workers).
## Quick start
1. Install:
pip install django-celery-inspect
2. Add "celery_inspect" to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
...
'celery_inspect',
]
3. Add the following to your urls.py:
url(r'^api/v1/celery-inspect/', include('celery_inspect.urls', namespace='celery_inspect')),
4. If you Desire to use DRF's Authentication to protect these endpoints (Optional).
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
}
## Usage:
1. http://localhost:8000/api/v1/celery-inspect/ping/
{
"worker2@localhost:8000": {
"ok": "pong"
},
"worker1@localhost:8000": {
"ok": "pong"
}
}
2. http://localhost:8000/api/v1/celery-inspect/active/
{
"worker2@localhost:8000": [],
"worker1@localhost:8000": []
}
3. http://localhost:8000/api/v1/celery-inspect/registered/
{
"worker2@localhost:8000": [
"core.tasks.db_backup",
"core.tasks.send_queued_emails",
"yy.tasks.assign_to_mongo",
"xx.tasks.check_for_new_registered",
"xx.tasks.create_and_associate_manager",
"qq.celery.debug_task"
],
"worker1@localhost:8000": [
"core.tasks.db_backup",
"core.tasks.send_queued_emails",
"yy.tasks.assign_to_mongo",
"xx.tasks.check_for_new_registered",
"xx.tasks.create_and_associate_manager",
"qq.celery.debug_task"
]
}
4. http://localhost:8000/api/v1/celery-inspect/scheduled/
{
"worker2@localhost:8000": [],
"worker1@localhost:8000": []
}
### If for some reason you can only deal with status codes (This feature will only work if you have django-celery installed)
1. http://localhost:8000/api/v1/celery-inspect/active-status/
- Returns 200 if all workers in WorkerState are up.
- Returns 404 if workers are down (WorkerState != then inspect()).
- Returns 501 if djcelery a.k.a django-celery is not installed.
Django reusable-app that uses Celery Inspect command to monitor workers via the [Django REST Framework](https://github.com/tomchristie/django-rest-framework).
The main idea is to be able to monitor celery workers from another external service or server via a REST API and figure out if they are running or not by using celery's own [Inspect API]
(http://docs.celeryproject.org/en/latest/userguide/workers.html#inspecting-workers).
## Quick start
1. Install:
pip install django-celery-inspect
2. Add "celery_inspect" to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
...
'celery_inspect',
]
3. Add the following to your urls.py:
url(r'^api/v1/celery-inspect/', include('celery_inspect.urls', namespace='celery_inspect')),
4. If you Desire to use DRF's Authentication to protect these endpoints (Optional).
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
}
## Usage:
1. http://localhost:8000/api/v1/celery-inspect/ping/
{
"worker2@localhost:8000": {
"ok": "pong"
},
"worker1@localhost:8000": {
"ok": "pong"
}
}
2. http://localhost:8000/api/v1/celery-inspect/active/
{
"worker2@localhost:8000": [],
"worker1@localhost:8000": []
}
3. http://localhost:8000/api/v1/celery-inspect/registered/
{
"worker2@localhost:8000": [
"core.tasks.db_backup",
"core.tasks.send_queued_emails",
"yy.tasks.assign_to_mongo",
"xx.tasks.check_for_new_registered",
"xx.tasks.create_and_associate_manager",
"qq.celery.debug_task"
],
"worker1@localhost:8000": [
"core.tasks.db_backup",
"core.tasks.send_queued_emails",
"yy.tasks.assign_to_mongo",
"xx.tasks.check_for_new_registered",
"xx.tasks.create_and_associate_manager",
"qq.celery.debug_task"
]
}
4. http://localhost:8000/api/v1/celery-inspect/scheduled/
{
"worker2@localhost:8000": [],
"worker1@localhost:8000": []
}
### If for some reason you can only deal with status codes (This feature will only work if you have django-celery installed)
1. http://localhost:8000/api/v1/celery-inspect/active-status/
- Returns 200 if all workers in WorkerState are up.
- Returns 404 if workers are down (WorkerState != then inspect()).
- Returns 501 if djcelery a.k.a django-celery is not installed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-celery-inspect-0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3712728bd87a142a17a777abf6c14bf90ffd383e4e013001c3e5463dda99df7b |
|
MD5 | 7e4965623f3a91f519acced15259c282 |
|
BLAKE2b-256 | 073134d84ba8e5c27c4f03de4e2b58df446b768342f434ee562268b6ec910268 |
Close
Hashes for django_celery_inspect-0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ff8a4fd458400ef97e16fc50fe061340bd3ffa3f018b7586cfbcef22620ffd9 |
|
MD5 | 55c3af9e16f4974d9687ebc96fa0385d |
|
BLAKE2b-256 | f200d1fafc87dd63ffe7f7f65646aa170e3cecafc2a1264583e9f7a4a3b659c4 |