Wait until database is ready

This commit is contained in:
Yi EungJun committed 2015-12-09 18:57:58 +09:00
1 parent aa1b246388
commit b4ad7f2119
3 files changed
+22 -4

No files matched your search

+1 -1
View File
@@ -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
+20 -2
View File
@@ -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