Skip to content

Commit

Permalink
Added logs to startup for debugging backend env
Browse files Browse the repository at this point in the history
  • Loading branch information
shahanneda committed Jun 10, 2024
1 parent 6d17f3b commit 7344358
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backend/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ class Config(object):

# put any configurations here that are common across all environments
# list of available configs: https://flask.palletsprojects.com/en/1.1.x/config/
print("running thiS in config!")
print("MG_DATABASE_URL:", os.getenv("MG_DATABASE_URL"))
print("MG_DB_NAME:", os.getenv("MG_DB_NAME"))

MONGODB_URL = os.getenv("MG_DATABASE_URL")
MONGODB_DB_NAME = os.getenv("MG_DB_NAME")

Expand Down
9 changes: 9 additions & 0 deletions backend/app/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from mongoengine import connect
import mongomock
import pymongo
import os


def init_app(app):
Expand All @@ -11,11 +12,19 @@ def init_app(app):
if "USE_MONGOMOCK_CLIENT" in app.config
else pymongo.MongoClient
)
print("doing this!!")
print("MG_DATABASE_URL:", os.getenv("MG_DATABASE_URL"))
print("app.config mgdb url", app.config["MONGODB_URL"])
print("app.config mg db name", app.config["MONGODB_DB_NAME"])
print("app.config", app.config)
print("mongodb url in" , "MONGODB_URL" in app.config )
print("mongodb db name in" , "MONGODB_DB_NAME" in app.config )
if "MONGODB_URL" in app.config and "MONGODB_DB_NAME" in app.config:
connect(
host=app.config["MONGODB_URL"],
mongo_client_class=mongo_client,
db=app.config["MONGODB_DB_NAME"],
)
else:
print("MG_DATABASE_URL:", os.getenv("MG_DATABASE_URL"))
raise Exception("MG_DATABASE_URL and MG_DB_NAME must be set in the env file.")

0 comments on commit 7344358

Please sign in to comment.