diff --git a/spiffworkflow-backend/bin/boot_server_in_docker b/spiffworkflow-backend/bin/boot_server_in_docker index a6f9bf0c..0a7fc6fe 100755 --- a/spiffworkflow-backend/bin/boot_server_in_docker +++ b/spiffworkflow-backend/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/spiffworkflow-backend/bin/spiffworkflow-realm.json b/spiffworkflow-backend/bin/spiffworkflow-realm.json index ee2bceaa..c2c2a71a 100644 --- a/spiffworkflow-backend/bin/spiffworkflow-realm.json +++ b/spiffworkflow-backend/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/spiffworkflow-backend/bin/wait_for_db_to_be_ready.py b/spiffworkflow-backend/bin/wait_for_db_to_be_ready.py new file mode 100644 index 00000000..00903a93 --- /dev/null +++ b/spiffworkflow-backend/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()