From 71e189afbc127b574cca8d02fc31b2e65aff0d52 Mon Sep 17 00:00:00 2001 From: burnettk Date: Sun, 16 Oct 2022 22:32:16 -0400 Subject: [PATCH] Squashed 'spiffworkflow-backend/' changes from 3fff3539..593f33ca 593f33ca wait for db to be ready option 706094a8 demo env and no ssl for spiff realm on that env git-subtree-dir: spiffworkflow-backend git-subtree-split: 593f33ca52ffb049fefd529c3a6bc011cb62e950 --- bin/boot_server_in_docker | 5 +++++ bin/spiffworkflow-realm.json | 5 ++++- bin/wait_for_db_to_be_ready.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 bin/wait_for_db_to_be_ready.py diff --git a/bin/boot_server_in_docker b/bin/boot_server_in_docker index a6f9bf0ce..0a7fc6fec 100755 --- a/bin/boot_server_in_docker +++ b/bin/boot_server_in_docker @@ -10,6 +10,11 @@ set -o errtrace -o errexit -o nounset -o pipefail # run migrations export FLASK_APP=/app/src/spiffworkflow_backend +if [[ "${WAIT_FOR_DB_TO_BE_READY:-}" == "true" ]]; then + echo 'Waiting for db to be ready...' + poetry run python ./bin/wait_for_db_to_be_ready.py +fi + if [[ "${DOWNGRADE_DB:-}" == "true" ]]; then echo 'Downgrading database...' poetry run flask db downgrade diff --git a/bin/spiffworkflow-realm.json b/bin/spiffworkflow-realm.json index ee2bceaad..c2c2a71a7 100644 --- a/bin/spiffworkflow-realm.json +++ b/bin/spiffworkflow-realm.json @@ -26,7 +26,7 @@ "oauth2DeviceCodeLifespan": 600, "oauth2DevicePollingInterval": 5, "enabled": true, - "sslRequired": "external", + "sslRequired": "NONE", "registrationAllowed": false, "registrationEmailAsUsername": false, "rememberMe": false, @@ -1254,6 +1254,7 @@ "secret": "JXeQExm0JhQPLumgHtIIqf52bDalHz0q", "redirectUris": [ "http://localhost:7000/*", + "http://67.205.133.116:7000/*", "http://167.172.242.138:7000/*" ], "webOrigins": [], @@ -1523,6 +1524,7 @@ "clientAuthenticatorType": "client-secret", "redirectUris": [ "http://localhost:7001/*", + "http://67.205.133.116:7000/*", "http://167.172.242.138:7001/*" ], "webOrigins": ["*"], @@ -1591,6 +1593,7 @@ "secret": "6o8kIKQznQtejHOdRhWeKorBJclMGcgA", "redirectUris": [ "http://localhost:7001/*", + "http://67.205.133.116:7000/*", "http://167.172.242.138:7001/*" ], "webOrigins": [], diff --git a/bin/wait_for_db_to_be_ready.py b/bin/wait_for_db_to_be_ready.py new file mode 100644 index 000000000..00903a93d --- /dev/null +++ b/bin/wait_for_db_to_be_ready.py @@ -0,0 +1,28 @@ +"""Grabs tickets from csv and makes process instances.""" + +from spiffworkflow_backend import get_hacked_up_app_for_script +from flask_bpmn.models.db import db +import sqlalchemy +import time + + +def try_to_connect(start_time: float) -> None: + try: + db.first_or_404('select 1') + except sqlalchemy.exc.DatabaseError as exception: + if time.time() - start_time > 15: + raise exception + else: + time.sleep(1) + try_to_connect(start_time) + +def main() -> None: + """Main.""" + app = get_hacked_up_app_for_script() + start_time = time.time() + with app.app_context(): + try_to_connect(start_time) + + +if __name__ == "__main__": + main()