Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bastien Versini
committed
Jun 5, 2018
1 parent
91376fc
commit 3e47d9e
Showing
4 changed files
with
45 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
# This will make sure the app is always imported when | ||
# Django starts so that shared_task will use this app. | ||
from .celery import app as celery_app | ||
|
||
__all__ = ['celery_app'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,38 @@ | ||
from __future__ import absolute_import, unicode_literals | ||
from celery import Celery | ||
from celery import task | ||
from celery.schedules import crontab | ||
from django.core import management | ||
import os | ||
import django | ||
import tasks | ||
|
||
celery = Celery('ateliersoude', broker='redis://password@redis:6379/0') #! | ||
os.environ[ 'DJANGO_SETTINGS_MODULE' ] = "settings" | ||
# set the default Django settings module for the 'celery' program. | ||
os.environ['DJANGO_SETTINGS_MODULE'] = 'ateliersoude.settings' | ||
|
||
@task() | ||
def add_photos_task( lad_id ): | ||
print("HelLO WORkLD") | ||
app = Celery('ateliersoude') | ||
|
||
app.conf.broker_url = 'redis://redis:6379/0' | ||
app.conf.result_backend = 'redis://redis:6379/0' | ||
app.conf.accept_content = ['application/json'] | ||
app.conf.result_serializer = 'json' | ||
app.conf.task_serializer = 'json' | ||
app.conf.timezone = 'Europe/Paris' | ||
app.conf.beat_schedule = { | ||
# every minute | ||
'every-minute': { | ||
'task': 'tasks.send_queued_mail', | ||
'schedule': crontab(), | ||
'args': () | ||
} | ||
} | ||
|
||
# Load task modules from all registered Django app configs. | ||
app.autodiscover_tasks() | ||
|
||
@app.task() | ||
def debug_task(self): | ||
print('Request: {0!r}'.format(self.request)) | ||
|
||
@app.task(name='tasks.send_queued_mail') | ||
def send_queued_mail(): | ||
management.call_command('send_queued_mail') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
cd /ateliersoude; | ||
celery worker --app=ateliersoude.celery:app -B -l INFO --pidfile="/tmp/celerybeat.pid" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ django-post_office | |
#sécurité | ||
itsdangerous | ||
#celery | ||
celery | ||
|
||
celery[redis] | ||
djangorestframework | ||
redis |