From 1b6ceeb435cf525f2e9a459742d4413881b5d6db Mon Sep 17 00:00:00 2001 From: Will Nilges Date: Fri, 1 Sep 2023 01:33:42 -0400 Subject: [PATCH] Working? (2/2) --- Dockerfile | 2 +- meshdb/__init__.py | 4 ++++ meshdb/db/setup.py | 1 + wsgi.py | 9 --------- 4 files changed, 6 insertions(+), 10 deletions(-) delete mode 100644 wsgi.py diff --git a/Dockerfile b/Dockerfile index 0fc0b201..6e9dad3a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,4 +9,4 @@ RUN pip install . # FIXME: This probably isn't the file structure we want. COPY . . -ENTRYPOINT gunicorn 'meshdb:create_app()' --graceful-timeout 5 --bind=0.0.0.0:8080 +ENTRYPOINT gunicorn 'meshdb:create_app()' --graceful-timeout 2 --bind=0.0.0.0:8080 diff --git a/meshdb/__init__.py b/meshdb/__init__.py index 47e2ef52..02be2d29 100644 --- a/meshdb/__init__.py +++ b/meshdb/__init__.py @@ -30,6 +30,10 @@ def create_app(): app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True app.config["WTF_CSRF_ENABLED"] = False + # Configure Database + from meshdb.db.setup import setup_db + setup_db() + db.init_app(app) import meshdb.auth.authmodels as authmodels diff --git a/meshdb/db/setup.py b/meshdb/db/setup.py index e7147fb9..108d5c30 100644 --- a/meshdb/db/setup.py +++ b/meshdb/db/setup.py @@ -13,6 +13,7 @@ def setup_db(): engine = create_db_engine() # TODO: Delete? if not database_exists(engine.url): + print("Database not found. Bootstrapping....") create_database(engine.url) print(database_exists(engine.url)) meshdb.models.baseModel.Base.metadata.create_all(engine) diff --git a/wsgi.py b/wsgi.py deleted file mode 100644 index 224299f5..00000000 --- a/wsgi.py +++ /dev/null @@ -1,9 +0,0 @@ -from meshdb import create_app -from meshdb.db.setup import setup_db - -print("Configuring DB...") -setup_db() - -app = create_app() - -app.run(host=app.config["IP"], port=app.config["PORT"])