Skip to content

Commit

Permalink
fixed celery config to properly execute crontab tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
rwblair committed Jan 19, 2016
1 parent d523173 commit d45b36c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
6 changes: 5 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ uwsgi:
- /var/www/static
links:
- postgres
- redis
env_file: .env
command: /app/uwsgi.sh
expose:
Expand All @@ -46,16 +47,19 @@ nginx:
redis:
restart: always
image: redis
links:
- postgres

worker:
build: .
command: celery worker -A open_fmri.celery -Q default -n default@%h --loglevel=debug
command: celery worker -B -A open_fmri -Q default -n default@%h --loglevel=debug
env_file: .env
volumes:
- .:/app
volumes_from:
- uwsgi
links:
- postgres
- redis
working_dir: /app

Expand Down
12 changes: 7 additions & 5 deletions open_fmri/apps/dataset/tasks.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import datetime
from datetime import datetime

from celery import shared_task, Celery

from celery.utils.log import get_task_logger

logger = get_task_logger(__name__)

app = Celery('open_fmri')
app.config_from_object('django.conf:settings.base')
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)


@app.task(name='test_parse')
def test_parse():
logger = test_parse.get_logger()
logger.info(str(datetime.now))
return datetime.now()

4 changes: 3 additions & 1 deletion open_fmri/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,11 @@
Queue('default', Exchange('default'), routing_key='default'),
)

CELERY_IMPORTS = ('open_fmri.apps.dataset.tasks', )

CELERYBEAT_SCHEDULE = {
'Parse Logs': {
'task': 'parse_test',
'task': 'test_parse',
'schedule': crontab()
},
}
Expand Down

0 comments on commit d45b36c

Please sign in to comment.