aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-06-03 13:35:46 +0100
committerGravatar Gareth Coles <[email protected]>2018-06-03 13:35:46 +0100
commitc71ebbe4b1c70f9dc415587b35112e9b34cd53f0 (patch)
treeee739f80cd48602c5c1d6b44835faad647ba8a2b
parent[Wiki] Fix actions not showing in some desirable cases (diff)
Make the site still work without RMQ
-rw-r--r--gunicorn_config.py41
1 files changed, 22 insertions, 19 deletions
diff --git a/gunicorn_config.py b/gunicorn_config.py
index 1ad1ce39..7c86851e 100644
--- a/gunicorn_config.py
+++ b/gunicorn_config.py
@@ -44,22 +44,25 @@ def _when_ready(server=None, output_func=None):
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}")
-
- if not DEBUG_MODE:
- producer = c.Producer()
- producer.publish(
- {
- "event": BotEventTypes.send_embed.value,
- "data": {
- "target": CHANNEL_DEV_LOGS,
- "title": "Site Deployment",
- "description": "The site has been deployed!"
- }
- },
- routing_key=BOT_EVENT_QUEUE
- )
+ try:
+ 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}")
+
+ if not DEBUG_MODE:
+ producer = c.Producer()
+ producer.publish(
+ {
+ "event": BotEventTypes.send_embed.value,
+ "data": {
+ "target": CHANNEL_DEV_LOGS,
+ "title": "Site Deployment",
+ "description": "The site has been deployed!"
+ }
+ },
+ routing_key=BOT_EVENT_QUEUE
+ )
+ except Exception as e:
+ output(f"Failed to declare RabbitMQ Queues: {e}")