Skip to content

Commit

Permalink
Wait for postgres to be available or fail
Browse files Browse the repository at this point in the history
  • Loading branch information
martinburchell committed Jul 31, 2024
1 parent 622be9e commit 32ea5dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 4 additions & 6 deletions intermine_builder/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ THE_MINE_NAME=${MINE_NAME:-biotestmine}
FORCE_MINE_BUILD=${FORCE_MINE_BUILD:-0}
IM_VERSION=${IM_VERSION:-}
BIO_VERSION=${BIO_VERSION:-}
THE_PGPORT=${PGPORT:-5432}

if [ -d ${THE_MINE_NAME} ] && [ ! -z "$(ls -A ${THE_MINE_NAME})" ] && [ ! $FORCE_MINE_BUILD ]; then
echo "$(date +%Y/%m/%d-%H:%M) Mine ${THE_MINE_NAME} already exists"
Expand Down Expand Up @@ -100,7 +101,7 @@ if [ ! -f /home/intermine/.intermine/${THE_MINE_NAME}.properties ]; then
sed -i "s/TOMCAT_USER/${TOMCAT_USER:-tomcat}/g" /home/intermine/.intermine/${THE_MINE_NAME}.properties
sed -i "s/TOMCAT_PWD/${TOMCAT_PWD:-tomcat}/g" /home/intermine/.intermine/${THE_MINE_NAME}.properties
sed -i "s/webapp.deploy.url=http:\/\/localhost:8080/webapp.deploy.url=http:\/\/${TOMCAT_HOST:-tomcat}:${TOMCAT_PORT:-8080}/g" /home/intermine/.intermine/${THE_MINE_NAME}.properties
sed -i "s/serverName=localhost/serverName=${PGHOST:-postgres}:${PGPORT:-5432}/g" /home/intermine/.intermine/${THE_MINE_NAME}.properties
sed -i "s/serverName=localhost/serverName=${PGHOST:-postgres}:${THE_PGPORT:-5432}/g" /home/intermine/.intermine/${THE_MINE_NAME}.properties


# echo "project.rss=http://localhost:$WORDPRESS_PORT/?feed=rss2" >> /home/intermine/.intermine/${THE_MINE_NAME}.properties
Expand Down Expand Up @@ -156,11 +157,8 @@ fi
echo "$(date +%Y/%m/%d-%H:%M) Connect and create Postgres databases" #>> /home/intermine/intermine/build.progress

# # Wait for database
# dockerize -wait tcp://postgres:$PGPORT -timeout 60s
until psql -U postgres -h ${PGHOST:-postgres} -c '\l'; do
echo >&2 "$(date +%Y%m%dt%H%M%S) Postgres is unavailable - sleeping"
sleep 1
done
# dockerize -wait tcp://postgres:$THE_PGPORT -timeout 60s
wait4x tcp postgres:5432 --timeout 120s
echo >&2 "$(date +%Y%m%dt%H%M%S) Postgres is up - executing command"

# Close all open connections to database
Expand Down
3 changes: 2 additions & 1 deletion intermine_builder/intermine_builder.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ RUN apk add --no-cache bash \
maven \
postgresql-client \
perl \
perl-utils
perl-utils \
wait4x

RUN apk add --no-cache build-base
RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing perl-moosex
Expand Down

0 comments on commit 32ea5dc

Please sign in to comment.