77source /docker-entrypoint.sh
88docker_setup_env
99
10+ # Append max connections arg if needed
11+ if [ $POSTGRES_MAX_CONNECTIONS -gt 0 ]; then
12+ set -- " $@ " -c max_connections=${POSTGRES_MAX_CONNECTIONS}
13+ fi
1014
1115# Check for presence of old/new directories, indicating a failed previous autoupgrade
1216echo " ----------------------------------------------------------------------"
@@ -30,26 +34,15 @@ echo "--------------------------------------------------------------------------
3034echo " No artifacts found from a failed previous autoupgrade. Continuing the process."
3135echo " -------------------------------------------------------------------------------"
3236
33- echo " DB STATUS: "
34- pg_ctl -D " $PGDATA " status
35-
3637if [ -n " $DATABASE_ALREADY_EXISTS " ]; then
3738
3839 echo " -----------------------------------------"
3940 echo " Performing checks on existing database..."
4041 echo " -----------------------------------------"
4142
42- # Just make sure postgres isn't still running for some reason
43- set +e
44- pg_ctl -D " $PGDATA " -m immedate stop
45- set -e
46-
47- # Remove any stale PID file
48- rm -f " ${PGDATA} /postmaster.pid"
49-
5043 # Make sure timescaledb library is set to preload (won't work otherwise)
5144 echo " ---------------------------------------------------------------------------------------"
52- echo " Existing postgresql.conf found checking for shared_preload_libraries = 'timescaledb'..."
45+ echo " Existing postgresql.conf found checking for shared_preload_libraries = 'timescaledb'..."
5346 echo " ---------------------------------------------------------------------------------------"
5447 RESULT=$( cat " $PGDATA /postgresql.conf" | grep " ^shared_preload_libraries = 'timescaledb'" || true)
5548
@@ -88,8 +81,18 @@ if [ -n "$DATABASE_ALREADY_EXISTS" ]; then
8881 echo " Postgres major version is newer than the existing DB, performing auto upgrade..."
8982 echo " ---------------------------------------------------------------------------------"
9083
84+ if [ -f " ${PGDATA} /postmaster.pid" ]; then
85+ echo " -----------------------------------------------------------------------------------------------------"
86+ echo " Looks like the server did not previously shutdown properly which will prevent pg_upgrade from working"
87+ echo " try stopping the whole stack, bringing only the postgresql container up and then stopping it again"
88+ echo " -----------------------------------------------------------------------------------------------------"
89+ exit 1
90+ fi
91+
9192 if [ ! -d " /usr/lib/postgresql/${DB_VERSION} " ]; then
93+ echo " --------------------------------------------------------------------------------------------------"
9294 echo " Postgres executable version '$DB_VERSION ' is not included in this image so cannot auto upgrade"
95+ echo " --------------------------------------------------------------------------------------------------"
9396 exit 1
9497 fi
9598
@@ -194,7 +197,7 @@ if [ -n "$DATABASE_ALREADY_EXISTS" ]; then
194197 echo " Copying reindex and TS version files across"
195198 echo " --------------------------------------------------------------"
196199 cp -f ${OLD} /OR_REINDEX_* ${PGDATA}
197- cp -f ${OLD} /TS_VERSION ${PGDATA}
200+ cp -f ${OLD} /OR_TS_VERSION ${PGDATA}
198201 echo " -------------------------------------------------------------------"
199202 echo " Copying reindex files is complete"
200203 echo " -------------------------------------------------------------------"
0 commit comments