First schedule

This commit is contained in:
Martyn Inglis
2016-03-09 14:41:36 +00:00
parent 03f5f01a51
commit fbfa176895
3 changed files with 25 additions and 11 deletions

View File

@@ -12,7 +12,14 @@ from sqlalchemy.exc import SQLAlchemyError
from app.aws import s3 from app.aws import s3
from datetime import datetime from datetime import datetime
from utils.template import Template from utils.template import Template
from utils.recipients import RecipientCSV, first_column_heading from utils.recipients import RecipientCSV
@notify_celery.task(name="log_this")
def do_test():
current_app.logger.info(
"here"
)
@notify_celery.task(name="process-job") @notify_celery.task(name="process-job")
@@ -27,9 +34,9 @@ def process_job(job_id):
) )
for recipient, personalisation in RecipientCSV( for recipient, personalisation in RecipientCSV(
s3.get_job_from_s3(job.bucket_name, job_id), s3.get_job_from_s3(job.bucket_name, job_id),
template_type=template.template_type, template_type=template.template_type,
placeholders=template.placeholders placeholders=template.placeholders
).recipients_and_personalisation: ).recipients_and_personalisation:
encrypted = encryption.encrypt({ encrypted = encryption.encrypt({

View File

@@ -1,3 +1,4 @@
from datetime import timedelta
from kombu import Exchange, Queue from kombu import Exchange, Queue
import os import os
@@ -35,12 +36,13 @@ class Config(object):
CELERY_TIMEZONE = 'Europe/London' CELERY_TIMEZONE = 'Europe/London'
CELERY_ACCEPT_CONTENT = ['json'] CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json' CELERY_TASK_SERIALIZER = 'json'
# CELERYBEAT_SCHEDULE = { CELERY_IMPORTS = ('app.celery.tasks',)
# 'refresh-queues': { CELERYBEAT_SCHEDULE = {
# 'task': 'refresh-services', 'tasks': {
# 'schedule': timedelta(seconds=5) 'task': 'log_this',
# } 'schedule': timedelta(seconds=5)
# } }
}
CELERY_QUEUES = [ CELERY_QUEUES = [
Queue('sms', Exchange('default'), routing_key='sms'), Queue('sms', Exchange('default'), routing_key='sms'),
Queue('email', Exchange('default'), routing_key='email'), Queue('email', Exchange('default'), routing_key='email'),
@@ -52,7 +54,6 @@ class Config(object):
Queue('bulk-email', Exchange('default'), routing_key='bulk-email'), Queue('bulk-email', Exchange('default'), routing_key='bulk-email'),
Queue('email-invited-user', Exchange('default'), routing_key='email-invited-user') Queue('email-invited-user', Exchange('default'), routing_key='email-invited-user')
] ]
CELERY_IMPORTS = ('app.celery.tasks',)
TWILIO_ACCOUNT_SID = os.getenv('TWILIO_ACCOUNT_SID') TWILIO_ACCOUNT_SID = os.getenv('TWILIO_ACCOUNT_SID')
TWILIO_AUTH_TOKEN = os.getenv('TWILIO_AUTH_TOKEN') TWILIO_AUTH_TOKEN = os.getenv('TWILIO_AUTH_TOKEN')
TWILIO_NUMBER = os.getenv('TWILIO_NUMBER') TWILIO_NUMBER = os.getenv('TWILIO_NUMBER')

6
scripts/run_celery_beat.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
set -e
source environment.sh
celery -A run_celery.notify_celery beat --loglevel=INFO