Use MONGODB_HOST env var because Wildduck uses that

This commit is contained in:
Lauri Võsandi 2021-06-13 14:11:44 +03:00
parent 317978c24a
commit a616c0b38a

View File

@ -3,9 +3,9 @@ import os
from motor.motor_asyncio import AsyncIOMotorClient from motor.motor_asyncio import AsyncIOMotorClient
from sanic import Sanic, response, exceptions from sanic import Sanic, response, exceptions
MONGO_URI = os.getenv("MONGO_URI") MONGODB_HOST = os.getenv("MONGODB_HOST")
if not MONGO_URI: if not MONGODB_HOST:
raise ValueError("No MONGO_URI specified") raise ValueError("No MONGODB_HOST specified")
PROMETHEUS_BEARER_TOKEN = os.getenv("PROMETHEUS_BEARER_TOKEN") PROMETHEUS_BEARER_TOKEN = os.getenv("PROMETHEUS_BEARER_TOKEN")
if not PROMETHEUS_BEARER_TOKEN: if not PROMETHEUS_BEARER_TOKEN:
@ -16,7 +16,7 @@ app = Sanic("exporter")
@app.listener("before_server_start") @app.listener("before_server_start")
async def setup_db(app, loop): async def setup_db(app, loop):
app.ctx.db = AsyncIOMotorClient(MONGO_URI).get_default_database() app.ctx.db = AsyncIOMotorClient(MONGODB_HOST).get_default_database()
async def wrap(i, prefix="wildduck_"): async def wrap(i, prefix="wildduck_"):