From bf291fbd8e78d86db1002016822c44f43129d68b Mon Sep 17 00:00:00 2001 From: jasquat Date: Fri, 24 Jun 2022 17:41:14 -0400 Subject: [PATCH] only load fixture data when starting the server w/ burnettk --- bin/boot_server_in_docker | 4 ++-- bin/run_server_locally | 3 ++- src/spiffworkflow_backend/__init__.py | 5 ----- wsgi.py | 6 ++++++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bin/boot_server_in_docker b/bin/boot_server_in_docker index 0f29a3a7..72c95a06 100755 --- a/bin/boot_server_in_docker +++ b/bin/boot_server_in_docker @@ -10,7 +10,7 @@ set -o errtrace -o errexit -o nounset -o pipefail # run migrations export FLASK_APP=/app/src/spiffworkflow_backend -if [ "${DOWNGRADE_DB:-}" = "true" ]; then +if [[ "${DOWNGRADE_DB:-}" == "true" ]]; then echo 'Downgrading database...' poetry run flask db downgrade fi @@ -32,4 +32,4 @@ if [[ "${APPLICATION_ROOT:-}" != "/" ]]; then fi # THIS MUST BE THE LAST COMMAND! -exec poetry run gunicorn ${additional_args} --bind "0.0.0.0:$SPIFFWORKFLOW_BACKEND_PORT" --workers=3 --timeout 90 --log-level debug wsgi:app +exec poetry run gunicorn ${additional_args} --bind "0.0.0.0:$port" --workers=3 --timeout 90 --log-level debug wsgi:app diff --git a/bin/run_server_locally b/bin/run_server_locally index f1bce703..79215922 100755 --- a/bin/run_server_locally +++ b/bin/run_server_locally @@ -17,5 +17,6 @@ if [[ -z "${BPMN_SPEC_ABSOLUTE_DIR:-}" ]]; then fi export FLASK_SESSION_SECRET_KEY=super_secret_key +export APPLICATION_ROOT="/" -FLASK_APP=src/spiffworkflow_backend poetry run flask run -p 7000 +./bin/boot_server_in_docker diff --git a/src/spiffworkflow_backend/__init__.py b/src/spiffworkflow_backend/__init__.py index f0742172..86158268 100644 --- a/src/spiffworkflow_backend/__init__.py +++ b/src/spiffworkflow_backend/__init__.py @@ -14,7 +14,6 @@ from spiffworkflow_backend.routes.admin_blueprint.admin_blueprint import admin_b from spiffworkflow_backend.routes.api_blueprint import api_blueprint from spiffworkflow_backend.routes.process_api_blueprint import process_api_blueprint from spiffworkflow_backend.routes.user_blueprint import user_blueprint -from spiffworkflow_backend.services.acceptance_test_fixtures import load_fixtures def create_app() -> flask.app.Flask: @@ -56,8 +55,4 @@ def create_app() -> flask.app.Flask: connexion_app.add_api("api.yml", base_path="/v1.0") - if os.environ.get("SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA") == "true": - with app.app_context(): - load_fixtures() - return app # type: ignore diff --git a/wsgi.py b/wsgi.py index 3ad7e8a6..2e8d2351 100644 --- a/wsgi.py +++ b/wsgi.py @@ -1,4 +1,10 @@ """This is my docstring.""" +import os from spiffworkflow_backend import create_app +from spiffworkflow_backend.services.acceptance_test_fixtures import load_fixtures app = create_app() + +if os.environ.get("SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA") == "true": + with app.app_context(): + load_fixtures()