Skip to content

Commit

Permalink
Environment queue (#199)
Browse files Browse the repository at this point in the history
* environment  queue

* change core. in template

* make format
  • Loading branch information
Keryc Diaz authored Jul 27, 2020
1 parent e3fbc58 commit a318125
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ ADD . /speid/
ENV PORT 3000
EXPOSE $PORT

CMD NEW_RELIC_LICENSE_KEY=${NEW_RELIC_LICENSE_KEY} NEW_RELIC_APP_NAME=speid newrelic-admin run-program celery worker -A speid.tasks.celery -D --loglevel=info -c 5 -Q cuenca.stp.account,cuenca.stp.new_order,recon.stp.transaction && \
CMD NEW_RELIC_LICENSE_KEY=${NEW_RELIC_LICENSE_KEY} NEW_RELIC_APP_NAME=speid newrelic-admin run-program celery worker -A speid.tasks.celery -D --loglevel=info -c 5 -Q ${CORE_ACCOUNT_QUEUE},${CORE_NEW_ORDER_QUEUE},${RECON_TRANSACTION_QUEUE} && \
NEW_RELIC_LICENSE_KEY=${NEW_RELIC_LICENSE_KEY} NEW_RELIC_APP_NAME=speid newrelic-admin run-program gunicorn --access-logfile=- --error-logfile=- --bind=0.0.0.0:3000 --workers=${SPEID_WORKERS:-5} speid:app
3 changes: 3 additions & 0 deletions env.template
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ IGNORED_EXCEPTIONS=Servicio no disponible
NEW_RELIC_LICENSE_KEY=foo
SEND_TRANSACTION_TASK=anytask
SEND_STATUS_TRANSACTION_TASK=anytask2
CORE_ACCOUNT_QUEUE=core.stp.account
CORE_NEW_ORDER_QUEUE=core.stp.new_order
RECON_TRANSACTION_QUEUE=recon.stp.transaction
8 changes: 5 additions & 3 deletions speid/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ def make_celery(app: Flask) -> Celery:
],
)
celery_app.conf.update(app.config)
celery_app.conf.task_default_queue = 'cuenca.stp.new_order'
celery_app.conf.task_default_queue = os.environ['CORE_NEW_ORDER_QUEUE']
celery_app.conf.task_routes = {
'speid.tasks.accounts.*': {'queue': 'cuenca.stp.account'},
'speid.tasks.transactions.*': {'queue': 'recon.stp.transaction'},
'speid.tasks.accounts.*': {'queue': os.environ['CORE_ACCOUNT_QUEUE']},
'speid.tasks.transactions.*': {
'queue': os.environ['RECON_TRANSACTION_QUEUE']
},
}

class ContextTask(celery_app.Task): # type: ignore
Expand Down

0 comments on commit a318125

Please sign in to comment.