Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elabftw/elabctl
Browse files Browse the repository at this point in the history
* 'master' of github.com:elabftw/elabctl:
  shellcheck
  useless echo
  bug/minor: MySql: fix healthcheck crash
  • Loading branch information
NicolasCARPi committed Dec 23, 2024
2 parents 5a37c99 + 696b883 commit c670f9b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions elabctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,23 @@ function update-db-schema
{
is-installed
# wait for mysql container to start, but only if there is one
if [ "$(docker ps | grep ${ELAB_MYSQL_CONTAINER_NAME})" ]; then
if docker ps | grep -q "${ELAB_MYSQL_CONTAINER_NAME}"; then
echo -n "Waiting for the MySQL container to be ready before running update..."
while [ "$(docker inspect -f {{.State.Health.Status}} ${ELAB_MYSQL_CONTAINER_NAME})" != "healthy" ]; do echo -n .; sleep 2; done; echo
while true; do
# check if healthcheck is available or else will crash (e.g. with older versions of elabFTW config files)
health_status=$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}no-healthcheck{{end}}' "${ELAB_MYSQL_CONTAINER_NAME}")
if [ "$health_status" == "healthy" ]; then
break
fi
if [ "$health_status" == "no-healthcheck" ]; then
echo -e "\nNo healthcheck found. Waiting for 20 seconds as fallback..."
sleep 20
break
fi
# wait and retry while showing user activity
echo -n .
sleep 2
done
fi
echo "Running command 'bin/console db:update' in the eLabFTW container now"
docker exec -it "${ELAB_WEB_CONTAINER_NAME}" bin/console db:update
Expand Down

0 comments on commit c670f9b

Please sign in to comment.