app: Use hostname instead of ip for database

This commit is contained in:
Yi EungJun 2016-01-25 15:42:54 +09:00
parent ac9ce4a2a9
commit 75bb4944ac
4 changed files with 4 additions and 7 deletions

View File

@ -37,8 +37,6 @@ Remove `volumes` directory
* Do not modify the Listen Address in Service Settings. * Do not modify the Listen Address in Service Settings.
* Rarely '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. database. Workaround: Restart the container.
* Sometimes database connection is misconfigured. Workaround: Delete
`volumes/app/mattermost/config/config.json` and restart the 'app' container.
## More informations ## More informations

View File

@ -23,7 +23,7 @@
}, },
"SqlSettings": { "SqlSettings": {
"DriverName": "postgres", "DriverName": "postgres",
"DataSource": "postgres://mmuser:mmuser_password@PG_ADDR:PG_PORT/mattermost?sslmode=disable&connect_timeout=10", "DataSource": "postgres://mmuser:mmuser_password@db:DB_PORT/mattermost?sslmode=disable&connect_timeout=10",
"DataSourceReplicas": [], "DataSourceReplicas": [],
"MaxIdleConns": 10, "MaxIdleConns": 10,
"MaxOpenConns": 10, "MaxOpenConns": 10,

View File

@ -4,8 +4,7 @@ echo -ne "Configure database connection..."
if [ ! -f $config ] if [ ! -f $config ]
then then
cp /config.template.json $config cp /config.template.json $config
sed -Ei "s/PG_ADDR/$PG_PORT_5432_TCP_ADDR/" $config sed -Ei "s/DB_PORT/$DB_PORT_5432_TCP_PORT/" $config
sed -Ei "s/PG_PORT/$PG_PORT_5432_TCP_PORT/" $config
echo OK echo OK
else else
echo SKIP echo SKIP
@ -13,7 +12,7 @@ fi
# Wait to avoid "panic: Failed to open sql connection pq: the database system is starting up" # Wait to avoid "panic: Failed to open sql connection pq: the database system is starting up"
echo "Wait until database is ready..." echo "Wait until database is ready..."
until nc -z $PG_PORT_5432_TCP_ADDR $PG_PORT_5432_TCP_PORT until nc -z db $DB_PORT_5432_TCP_PORT
do do
sleep 1 sleep 1
done done

View File

@ -6,7 +6,7 @@ db:
app: app:
build: app build: app
links: links:
- db:pg - db:db
volumes: volumes:
- ./volumes/app/mattermost/config:/mattermost/config:rw - ./volumes/app/mattermost/config:/mattermost/config:rw
- ./volumes/app/mattermost/data:/mattermost/data:rw - ./volumes/app/mattermost/data:/mattermost/data:rw