2022-10-12 14:22:22 +00:00
#!/usr/bin/env bash
function error_handler() {
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
exit "$2"
}
trap 'error_handler ${LINENO} $?' ERR
set -o errtrace -o errexit -o nounset -o pipefail
2023-05-06 19:17:48 +00:00
port="${SPIFFWORKFLOW_BACKEND_PORT:-7000}"
2023-08-21 16:29:25 +00:00
proces_model_dir="${1:-}"
if [[ "$proces_model_dir" == "acceptance" ]]; then
2022-10-12 19:28:52 +00:00
export SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA=true
export SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME=acceptance_tests.yml
2023-08-21 16:29:25 +00:00
SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR=$(./bin/find_sample_process_models)
elif [[ "$proces_model_dir" == "localopenid" ]]; then
2023-05-06 19:17:48 +00:00
export SPIFFWORKFLOW_BACKEND_OPEN_ID_SERVER_URL="http://localhost:$port/openid"
export SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME="example.yml"
2023-08-21 16:29:25 +00:00
SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR=$(./bin/find_sample_process_models)
else
SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR="$proces_model_dir"
2022-10-12 19:28:52 +00:00
fi
2023-08-21 16:29:25 +00:00
export SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR
2022-10-12 19:28:52 +00:00
2022-10-12 14:22:22 +00:00
if [[ -z "${SPIFFWORKFLOW_BACKEND_ENV:-}" ]]; then
2023-02-07 20:02:47 +00:00
export SPIFFWORKFLOW_BACKEND_ENV=local_development
2022-10-12 14:22:22 +00:00
fi
2023-03-12 22:20:29 +00:00
# export FLASK_SESSION_SECRET_KEY="super_secret_key"
export FLASK_SESSION_SECRET_KEY="e7711a3ba96c46c68e084a86952de16f"
2023-02-15 22:21:37 +00:00
export SPIFFWORKFLOW_BACKEND_APPLICATION_ROOT="/"
2022-10-12 14:22:22 +00:00
if [[ -n "${SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA:-}" ]]; then
./bin/boot_server_in_docker
else
2022-10-12 19:28:52 +00:00
export FLASK_DEBUG=1
if [[ "${SPIFFWORKFLOW_BACKEND_RUN_DATA_SETUP:-}" != "false" ]]; then
2023-02-15 22:07:12 +00:00
SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER=false SPIFFWORKFLOW_BACKEND_FAIL_ON_INVALID_PROCESS_MODELS=false poetry run python bin/save_all_bpmn.py
2022-10-12 19:28:52 +00:00
fi
2023-01-17 17:23:51 +00:00
2023-02-15 22:07:12 +00:00
if [[ -z "${SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER:-}" ]]; then
SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER=true
2023-01-17 17:23:51 +00:00
fi
# this line blocks
2023-05-08 19:36:57 +00:00
SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER="${SPIFFWORKFLOW_BACKEND_RUN_BACKGROUND_SCHEDULER}" FLASK_APP=src/spiffworkflow_backend poetry run flask run -p "$port" --host=0.0.0.0
2022-10-12 14:22:22 +00:00
fi