From b2ebe36c28e91ccca27dd035da50cb6c82ce9cc3 Mon Sep 17 00:00:00 2001 From: Lukas Wingerberg Date: Tue, 31 Oct 2023 23:05:34 +0100 Subject: [PATCH] add error_log function that exit 1's implicitely --- docker/init_scripts/init | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/docker/init_scripts/init b/docker/init_scripts/init index 0dd15946d..ab50cd962 100755 --- a/docker/init_scripts/init +++ b/docker/init_scripts/init @@ -15,9 +15,6 @@ ENABLE_EXPERIMENTAL_REDIS="${ENABLE_EXPERIMENTAL_REDIS:="false"}" # (this env var is currently undocumented and usually just needed for development purposes) INIT_DEBUG="${INIT_DEBUG:="false"}" -# switch to backend directory -cd /backend || { echo "/backend directory doesn't seem to exist"; exit 1; } - # print debug log output if enabled debug_log () { if [ "${INIT_DEBUG}" == "true" ]; then @@ -30,6 +27,12 @@ info_log () { echo "INFO: [init][$(date +"%Y-%m-%d %T")]" "${@}" } +# print debug log output if enabled +error_log () { + echo "ERROR: [init][$(date +"%Y-%m-%d %T")]" "${@}" + exit 1 +} + # function that runs or main process and creates a corresponding PID file, # sadly uvicorn can not do that itself start_bin_uvicorn () { @@ -83,6 +86,9 @@ watchdog_process_pid () { fi } +# switch to backend directory +cd /backend || { error_log "/backend directory doesn't seem to exist"; } + # function definition done, lets start our main loop while true; do # Run needed database migrations on startup, @@ -92,8 +98,7 @@ while true; do debug_log "database schema migrations suceeded" ALEMBIC_SUCCESS="true" else - echo "Something went horribly wrong with our database" - exit 1 + error_log "Something went horribly wrong with our database" fi else debug_log "database schema already upgraded during current containerlifecycle"