Skip to content

Commit 92aae1b

Browse files
committed
Close server with descriptive error on invalid URL config
1 parent 6d2333a commit 92aae1b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

oioioi/notifications/server/server.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from typing import Union
23
from socketify import App, OpCode, WebSocket
34
import json
@@ -33,8 +34,16 @@ def run(self) -> None:
3334
self.app.run()
3435

3536
async def on_start(self) -> None:
36-
await self.auth.connect()
37-
await self.queue.connect()
37+
try:
38+
await self.auth.connect()
39+
await self.queue.connect()
40+
self.logger.info("Notification server started successfully")
41+
except Exception as e:
42+
self.logger.error(f"""
43+
Error starting notification server: {str(e)}.
44+
This usually means a configuration error related to RabbitMQ. Closing server.
45+
""")
46+
sys.exit(1)
3847

3948
def on_ws_upgrade(self, res, req, socket_context):
4049
"""

0 commit comments

Comments
 (0)