diff options
author | 2018-05-30 22:38:54 +0100 | |
---|---|---|
committer | 2018-05-30 22:38:54 +0100 | |
commit | aaa387a5b3bdb9bc416690dccef66196c76d373e (patch) | |
tree | 270900787f1f8d76a97279f277fb281d45f37859 /gunicorn_config.py | |
parent | Add FAQ about LPTHW (diff) |
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
Diffstat (limited to 'gunicorn_config.py')
-rw-r--r-- | gunicorn_config.py | 12 |
1 files changed, 12 insertions, 0 deletions
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}") |