Skip to content

Commit b140e83

Browse files
committed
Improve engine container startup logic for migrations
Prior to this change, the script always attempted to bring up the engine and mariadb containers, regardless of their current status. This change checks if the engine and mariadb containers are already running before attempting to start them, providing clearer messaging based on the situation.
1 parent ba22fbb commit b140e83

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

core/scripts/init.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ set -e
1212

1313
# Bootstrapping engineblock means initialising the database
1414
printf "\n"
15-
echo -e "${ORANGE}Bring up the engineblock Production container to bootstrap the database using the Production container's migrations${NOCOLOR}"
16-
echo "Comment the two lines below to run the migrations from your own running engine container (ensure your EB is running)."
17-
echo
1815

1916
# Wait for engine to come up; not health yet because we might nee to initialialize db
20-
docker compose up -d engine mariadb
17+
engine_running=$(docker compose ps -q --status running engine mariadb | wc -l)
18+
if [[ "$engine_running" -lt 2 ]]; then
19+
docker compose up -d engine mariadb
20+
echo -e "${ORANGE}Bringing up the EB production container for migrations${NOCOLOR}"
21+
else
22+
echo -e "${ORANGE}Using the currently running engine container for migrations${NOCOLOR}"
23+
fi
2124
docker compose exec engine timeout 300 bash -c 'while [[ "$(curl -k -s -o /dev/null -w ''%{http_code}'' localhost/internal/info)" != "200" ]]; do sleep 5; done' || false
2225

2326
echo

0 commit comments

Comments
 (0)