Django Serverless Cron
Project description
django-serverless-cron is a Django app with a simpler approach running cron jobs (mostly in a serverless environment) through HTTP requests with an integration with the Django admin. This allows you to run any task without having to manage always-on infrastructure.
There is also an option to run jobs via management commands and the Django admin.
Documentation
Documentation is graciously hosted at https://django-serverless-cron.readthedocs.io.
Quickstart
Installation
Install Django Serverless Cron:
pip install django-serverless-cron
Settings
Add it to your INSTALLED_APPS:
INSTALLED_APPS = (
# ...
'django_serverless_cron'
# ...
)
Add jobs to your settings file:
CRONJOBS = [
# (
# '1_hours', # frequency (days, minutes, hours, weeks) -> in this case, every one hour
# 'mail.jobs.send_mail_function', # path to task/function functions -> in this case, send_mail_function()
# {'kwarg1': 'foo'} # kwargs passed to the function
# ),
(
'1_day',
'your_app.services.your_job_function',
{'kwarg1': 'foo', 'kwarg2': 'bar'}
),
(
'1_hour',
'mail.jobs.send_mail_function',
{"is_bulk": True}
),
]
URL patterns
Add the jobs to your URL patterns:
from django_serverless_cron import urls as django_serverless_cron_urls
urlpatterns = [
# ...
url(r'^', include(django_serverless_cron_urls))
#...
]
Running Jobs
In Development
Running Jobs through HTTP requests
Call the /run path to run all jobs:
Example:
curl http://localhost:8000/run
or
import requests
x = requests.get('http://localhost:8000/run')
In Production
Similar to in development, we can call the /run path via managed services which are usually ridiculously cheap. Examples:
Tests
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
Development commands
pip install -r requirements_dev.txt invoke -l
Credits
Tools used in rendering this package:
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 Distributions
Built Distribution
Hashes for django_serverless_cron-0.1.1a7-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | beae598c81162ed6be799ab0a142d8ab5fd1a30b942167cbfce187c545b79d9c |
|
MD5 | f10bbf5e543cfbc415964746ae2bfcee |
|
BLAKE2b-256 | 5361a1b51b006fa22cdb25b8254fb9b5c5421a6961d9bb0cb19f9a572b162da3 |