Skip to content

Commit

Permalink
Wait until database is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
Yi EungJun committed Dec 9, 2015
1 parent aa1b246 commit b4ad7f2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Remove `volumes` directory
## Known Issues

* Do not modify the Listen Address in Service Settings.
* Sometimes 'app' container fails to start because of "connection refused" to
* Rarely 'app' container fails to start because of "connection refused" to
database. Workaround: Restart the container.
* Sometimes database connection is misconfigured. Workaround: Delete
`volumes/app/mattermost/config/config.json` and restart the 'app' container.
Expand Down
2 changes: 1 addition & 1 deletion app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:14.04

RUN apt-get update && apt-get -y upgrade && apt-get -y install wget
RUN apt-get update && apt-get -y upgrade && apt-get -y install wget netcat
RUN mkdir -p /mattermost/data

RUN touch /etc/init/mattermost.conf
Expand Down
22 changes: 20 additions & 2 deletions app/docker-entry.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
#!/bin/bash
echo Starting Platform
config=/mattermost/config/config.json
if [ ! -f $config ]; then
echo -ne "Configure database connection..."
if [ ! -f $config ]
then
cp /config.template.json $config
sed -Ei "s/PG_ADDR/$PG_PORT_5432_TCP_ADDR/" $config
sed -Ei "s/PG_PORT/$PG_PORT_5432_TCP_PORT/" $config
echo OK
else
echo SKIP
fi

echo -n "Wait until database is ready..."
until nc -z $PG_PORT_5432_TCP_ADDR $PG_PORT_5432_TCP_PORT
do
echo -n .
sleep 1
done

# Wait to avoid "panic: Failed to open sql connection pq: the database system is starting up"
sleep 1

echo "OK"

echo "Starting platform"
cd /mattermost/bin
./platform

0 comments on commit b4ad7f2

Please sign in to comment.