Fix issue with stats startup causing ATC to terminate when restarting on a running DB with stats already enabled
@@ -15,13 +15,18 @@ go install github.com/concourse/atc/cmd/atc
pg_port=${POSTGRES_PORT:-6543}
external_ip="$($ROOT/dev/util/external-ip)"
docker_postgres="${DOCKER_POSTGRES:-concourse-db}"
+grep_message="ERROR"
until docker run --rm --name create-db --link ${docker_postgres}:postgres postgres:alpine createdb -U postgres -h postgres atc 2>&1 | grep 'already exists' >/dev/null; do
echo creating database atc in ${docker_postgres}...
sleep 1
done
-docker run --rm --name enable-stats --link ${docker_postgres}:postgres postgres:alpine psql -c 'create extension pg_stat_statements' -U postgres -h postgres atc
+if [ $(docker run --rm --name enable-stats --link ${docker_postgres}:postgres postgres:alpine psql -c "create extension pg_stat_statements" -U postgres -h postgres atc 2>&1 | grep -c ${grep_message} ) != 0 ] ; then
+ echo "Stats already enabled"
+else
+ echo "Stats enabled"
+fi
# run from atc dir so that an atc built with 'make DEV=-dev' can find the assets
cd $ROOT/src/github.com/concourse/atc
