From aaa387a5b3bdb9bc416690dccef66196c76d373e Mon Sep 17 00:00:00 2001 From: Gareth Coles Date: Wed, 30 May 2018 22:38:54 +0100 Subject: RabbitMQ mixin, powered by Kombu (#84) * [RMQ] Add Kombi an an RMQMixin, as well as some constants * [RMQ] Fix example in mixin docstring * Update Pipfile.lock - for some reason, pipenv didn't lock kombu --- gunicorn_config.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gunicorn_config.py') diff --git a/gunicorn_config.py b/gunicorn_config.py index 37a91367..6c9cf04a 100644 --- a/gunicorn_config.py +++ b/gunicorn_config.py @@ -1,6 +1,10 @@ import re +from kombu import Connection + +from pysite.constants import RMQ_HOST, RMQ_PASSWORD, RMQ_PORT, RMQ_USERNAME from pysite.migrations.runner import run_migrations +from pysite.queues import QUEUES STRIP_REGEX = re.compile(r"<[^<]+?>") WIKI_TABLE = "wiki" @@ -34,3 +38,11 @@ def _when_ready(server=None, output_func=None): output(f"Created the following tables: {tables}") run_migrations(db, output=output) + + output("Declaring RabbitMQ queues...") + + with Connection(hostname=RMQ_HOST, userid=RMQ_USERNAME, password=RMQ_PASSWORD, port=RMQ_PORT) as c: + with c.channel() as channel: + for name, queue in QUEUES.items(): + queue.declare(channel=channel) + output(f"Queue declared: {name}") -- cgit v1.2.3