Skip to content

Commit e7e3c7d

Browse files
committed
Fixed(?): Multiple celery workers.
These changes should start up the workers to only take tasks from the correct queue, and should inform the django apps as to which queue to send tasks too. Obviously I won't know if this works until we try running it on the live server, but it seems to work locally (I can start multiple celery instances connected to the project, and only the one pointed at the correct queue will take the tasks) #210
1 parent c0c2cb0 commit e7e3c7d

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

celery_start_dev.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ source ${VIRTUAL_ENV}/bin/activate
88
# Move to project directory
99
cd ${PROJECT_PATH}
1010
# Run your worker... old: exec celery worker -A elvis -l DEBUG --loglevel=INFO
11-
exec celery worker -A elvis -l info --pidfile="/run/celery/%n-dev.pid"
11+
exec celery worker -A elvis -l info --pidfile="/run/celery/%n-dev.pid" -Q elvis-dev

celery_start_prod.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ source ${VIRTUAL_ENV}/bin/activate
88
# Move to project directory
99
cd ${PROJECT_PATH}
1010
# Run your worker... old: exec celery worker -A elvis -l DEBUG --loglevel=INFO
11-
exec celery worker -A elvis -l info --pidfile="/run/celery/%n-prod.pid"
11+
exec celery worker -A elvis -l info --pidfile="/run/celery/%n-prod.pid" -Q elvis-prod

elvis/settings.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
2020
import os
2121
import re
22+
from kombu import Exchange, Queue
2223

2324
BASE_DIR = os.path.abspath('./')
2425

@@ -259,14 +260,19 @@
259260
CELERY_TASK_SERIALIZER = 'json'
260261
CELERY_RESULT_SERIALIZER = 'json'
261262
CELERY_ACCEPT_CONTENT = ['json']
262-
263+
CELERY_QUEUE_DICT = {'queue': 'elvis-{}'.format(SETTING_TYPE)}
264+
CELERY_ROUTES = {'elvis.zip_files': CELERY_QUEUE_DICT,
265+
'elvis.delete_zip_file': CELERY_QUEUE_DICT,
266+
'elvis.rebuild_suggesters': CELERY_QUEUE_DICT}
263267

264268
# Elvis Web App Settings
265269
# ======================
266270
ELVIS_EXTENSIONS = ['.xml', '.mxl', '.krn', '.md', '.nwc', '.tntxt', '.capx',
267271
'.abc', '.mid', '.midi', '.pdf', '.mei', '.ma', '.md2', '.json']
268272
ELVIS_BAD_PREFIX = ['.', '..', '_', '__']
269-
SUGGEST_DICTS = ['composerSuggest', 'pieceSuggest', 'collectionSuggest', 'languageSuggest', 'genreSuggest', 'locationSuggest', 'sourceSuggest', 'instrumentSuggest', 'tagSuggest']
273+
SUGGEST_DICTS = ['composerSuggest', 'pieceSuggest', 'collectionSuggest',
274+
'languageSuggest', 'genreSuggest', 'locationSuggest',
275+
'sourceSuggest', 'instrumentSuggest', 'tagSuggest']
270276

271277

272278
LOGGING = {

0 commit comments

Comments
 (0)