diff --git a/Dockerfile b/Dockerfile index e0db067..eb39050 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,7 +36,7 @@ RUN set -eux \ netcat postgresql-${POSTGRES_MAJOR_VERSION}-ogr-fdw \ postgresql-${POSTGRES_MAJOR_VERSION}-postgis-${POSTGIS_MAJOR}-scripts \ postgresql-plpython3-${POSTGRES_MAJOR_VERSION} postgresql-${POSTGRES_MAJOR_VERSION}-pgrouting \ - postgresql-server-dev-${POSTGRES_MAJOR_VERSION} + postgresql-server-dev-${POSTGRES_MAJOR_VERSION} postgresql-${POSTGRES_MAJOR_VERSION}-cron RUN echo $POSTGRES_MAJOR_VERSION >/tmp/pg_version.txt diff --git a/scripts/env-data.sh b/scripts/env-data.sh index fdc7069..f288f83 100644 --- a/scripts/env-data.sh +++ b/scripts/env-data.sh @@ -249,7 +249,7 @@ if [ -z "$EXTRA_CONF" ]; then fi if [ -z "${SHARED_PRELOAD_LIBRARIES}" ]; then - SHARED_PRELOAD_LIBRARIES='' + SHARED_PRELOAD_LIBRARIES='pg_cron' fi if [ -z "$PASSWORD_AUTHENTICATION" ]; then diff --git a/scripts/setup-conf.sh b/scripts/setup-conf.sh index 900487d..5c214c8 100644 --- a/scripts/setup-conf.sh +++ b/scripts/setup-conf.sh @@ -36,6 +36,7 @@ shared_preload_libraries = '${SHARED_PRELOAD_LIBRARIES}' cron.database_name = '${SINGLE_DB}' password_encryption= '${PASSWORD_AUTHENTICATION}' timezone='${TIMEZONE}' +cron.use_background_workers = on EOF # This script will setup necessary replication settings diff --git a/scripts/setup-database.sh b/scripts/setup-database.sh index 7bd2861..c255f6b 100644 --- a/scripts/setup-database.sh +++ b/scripts/setup-database.sh @@ -79,6 +79,11 @@ for db in $(echo ${POSTGRES_DBNAME} | tr ',' ' '); do fi done +CRON_LOCKFILE="${ROOT_CONF}/.cron_ext.lock" +if [ ! -f "${CRON_LOCKFILE}" ]; then + su - postgres -c "psql -c 'CREATE EXTENSION IF NOT EXISTS pg_cron cascade;' ${SINGLE_DB}" + touch ${CRON_LOCKFILE} +fi # This should show up in docker logs afterwards su - postgres -c "psql -l 2>&1"