diff --git a/docker-compose.yaml b/docker-compose.yaml index 497ad2b2..29a20e59 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -27,5 +27,7 @@ services: tty: true volumes: - .:/modmail + env_file: + - .env environment: database_uri: postgres://modmail:modmail@postgres:5432/modmail diff --git a/docs/contributing.md b/docs/contributing.md index dba40979..1acd99bc 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -165,7 +165,7 @@ $ psql -qd postgres Run the following queries to create the user and database: ```psql -CREATE USER voting WITH SUPERUSER PASSWORD 'modmail'; +CREATE USER modmail WITH SUPERUSER PASSWORD 'modmail'; CREATE DATABASE modmail WITH OWNER modmail; ``` @@ -217,7 +217,7 @@ $ poetry run alembic upgrade heads 5. Open the file with any text editor and write the bot token and the database URL to the files in this format: * `TOKEN="my_token"`. - * `DATABASE_URI=postgresql+asyncpg://modmail:modmail@localhost:5432/modmail` + * `DATABASE_URI=postgres://modmail:modmail@localhost:5432/modmail` !!! note If you configured PostgreSQL in a different manner or you are not hosting it locally, then you will need to diff --git a/modmail/bot.py b/modmail/bot.py index 91ba2b44..eb830c2d 100644 --- a/modmail/bot.py +++ b/modmail/bot.py @@ -1,6 +1,7 @@ import asyncio import logging import signal +import sys import typing as t import arrow @@ -89,10 +90,8 @@ async def init_db(self) -> None: self.logger.info("Generating database schema via Tortoise...") await Tortoise.generate_schemas() except Exception as e: - self.logger.error( - f"DB connection at {CONFIG.bot.sqlalchemy_database_uri} not successful, raised:\n{e}" - ) - exit() + self.logger.error(f"DB connection at {CONFIG.bot.database_uri} not successful, raised:\n{e}") + sys.exit(e) async def start(self, token: str, reconnect: bool = True) -> None: """