From 75bb4944acb40d78c9ccb9d3e419b84c34d5f428 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Mon, 25 Jan 2016 15:42:54 +0900 Subject: [PATCH] app: Use hostname instead of ip for database --- README.md | 2 -- app/config.template.json | 2 +- app/docker-entry.sh | 5 ++--- docker-compose.yml | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 30cc8aa..0aecb0b 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,6 @@ Remove `volumes` directory * Do not modify the Listen Address in Service Settings. * 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. ## More informations diff --git a/app/config.template.json b/app/config.template.json index d293c8f..7f5e90c 100644 --- a/app/config.template.json +++ b/app/config.template.json @@ -23,7 +23,7 @@ }, "SqlSettings": { "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": [], "MaxIdleConns": 10, "MaxOpenConns": 10, diff --git a/app/docker-entry.sh b/app/docker-entry.sh index a40b353..7574888 100644 --- a/app/docker-entry.sh +++ b/app/docker-entry.sh @@ -4,8 +4,7 @@ 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 + sed -Ei "s/DB_PORT/$DB_PORT_5432_TCP_PORT/" $config echo OK else echo SKIP @@ -13,7 +12,7 @@ fi # Wait to avoid "panic: Failed to open sql connection pq: the database system is starting up" 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 sleep 1 done diff --git a/docker-compose.yml b/docker-compose.yml index 47019d5..8edcea5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ db: app: build: app links: - - db:pg + - db:db volumes: - ./volumes/app/mattermost/config:/mattermost/config:rw - ./volumes/app/mattermost/data:/mattermost/data:rw