feature/pre-release-fixes #3

Merged
Typhus merged 3 commits from feature/pre-release-fixes into main 2026-05-28 11:16:26 +00:00
Showing only changes of commit 11724ad0d9 - Show all commits
+11
View File
@@ -1,8 +1,10 @@
import logging
import sys
from beanie import init_beanie
from pymongo import AsyncMongoClient
from pymongo.asynchronous.collection import AsyncCollection
from pymongo.errors import ServerSelectionTimeoutError, OperationFailure
from elm.types import User, Transaction, Ticket, Seat, CateringTypes
from elm.types.ConfigurationTypes import DatabaseConfiguration
@@ -30,6 +32,15 @@ class DatabaseService:
if self._client is None:
self._client = AsyncMongoClient(mongo_uri)
try:
await self._client.admin.command("ping")
except ServerSelectionTimeoutError:
print("Could not connect to mongodb")
sys.exit(1)
except OperationFailure:
print("Authentication with mongodb failed")
sys.exit(1)
self._database = self._client[
self._db_config.database_name
]