Skip to content

Commit

Permalink
Actually check for healthy state of MySQL container rather than wait …
Browse files Browse the repository at this point in the history
…15 seconds before running db update.

See elabftw/elabftw#4948.
  • Loading branch information
NicolasCARPi committed Mar 12, 2024
1 parent 7bf280e commit 44a6d70
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog for elabctl

## Version 5.0.0

The major version bump is simply to align with the rest of the elabftw related repositories, it has no other meaning.

* Actually check for healthy state of MySQL container rather than wait 15 seconds before running db update. See elabftw/elabftw#4948.

## Version 3.6.4

* Use `mktemp` command to create temporary directory to write temporary files to, without another user being able to read or modify it.
Expand Down
11 changes: 7 additions & 4 deletions elabctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# https://github.com/elabftw/elabctl/
# © 2022 Nicolas CARPi @ Deltablot
# License: GPLv3
declare -r ELABCTL_VERSION='3.6.4'
declare -r ELABCTL_VERSION='5.0.0'

# default backup dir
declare BACKUP_DIR='/var/backups/elabftw'
Expand Down Expand Up @@ -550,9 +550,12 @@ function update
function update-db-schema
{
is-installed
echo "Waiting 15 seconds for the container to start before running update..."
sleep 15
echo "Running command 'bin/console db:update' in the container now"
# wait for mysql container to start, but only if there is one
if [ "$(docker ps | grep ${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
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 44a6d70

Please sign in to comment.