git clone git://github.com/orn0t/celery-tm.git
cd celety-tm
pip install -r requirements.txt
If you are using Centos7:
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
sudo rpm -ivh epel-release-7-5.noarch.rpm
sudo yum -y updates
sudo yum install redis -y
sudo systemctl start redis.service
Or even on MacOS:
brew install redis
# starting on system load, not necessary:
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Check settings.py
for parameters you need:
# Web API configuration
CELERY_TM_API_HOST = '127.0.0.1'
CELERY_TM_API_PORT = 5000
# Task schedule configuration
CELERY_TM_BROKER = 'redis://localhost:6379/0'
CELERY_TM_TIMEZONE = 'Europe/Kiev'
python app.py
celery -A worker worker
celery -A beat beat
POST /api/v1.0/schedule
data: {
"function": "module.function_to_run",
"schedule": "1/4 * * * *",
"args": [1, 2, "other_argument"]
}
Result:
Status: 201 CREATED
{
"function": "time.time",
"schedule": "1 * * * *",
"id": 2,
"created": "Wed, 15 Mar 2017 14:06:21 -0000"
}
POST /api/v1.0/schedule
data: {
"function": "module.function_to_run",
"schedule": "now"
}
POST /api/v1.0/schedule
data: {
"function": "module.function_to_run",
"schedule": "3000"
}
DELETE /api/v1.0/schedule
data: {
"id": 1
}
Result:
Status: 204
GET /api/v1.0/schedule
Result:
Status: 200
[
{
"function": "time.time",
"schedule": "1 * * * *",
"id": 1,
"created": "Wed, 15 Mar 2017 16:44:07 -0000"
},
...
]
GET /api/v1.0/schedule?id=2
Result:
Status: 200
[
{
"function": "time.time",
"schedule": "1 * * * *",
"id": 2,
"created": "Wed, 15 Mar 2017 16:44:07 -0000"
}
]
GET /api/v1.0/schedule?recurring=1