-
Notifications
You must be signed in to change notification settings - Fork 36
/
pgconfig.sh.erb
59 lines (53 loc) · 2.41 KB
/
pgconfig.sh.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash -e
<% if !p("databases.enable_trace").nil? && p("databases.enable_trace") %>
ENABLE_TRACE=1
set -x # if you want tracing disabled, set 'databases.enable_traces: false' in the manifest
<% else %>
ENABLE_TRACE=0
# set -x # uncomment it if you want to enable tracing in all control scripts
<% end %>
JOB_DIR=/var/vcap/jobs/postgres
current_version="<%=p('databases.version')%>"
pgversion_current=postgres-$(MAJOR_VERSION=<%=p('databases.version')%> ${JOB_DIR}/packages/postgres-yq-4/bin/yq '.postgresql.major_version[env(MAJOR_VERSION)].minor_version' /var/vcap/jobs/postgres/config/used_postgresql_versions.yml)
PACKAGE_DIR="/var/vcap/packages/${pgversion_current%.*}"
STORE_DIR=/var/vcap/store
PG_STORE_DIR=${STORE_DIR}/postgres
VERSION_FILE=${PG_STORE_DIR}/POSTGRES_DATA_VERSION
DATA_DIR="${PG_STORE_DIR}/${pgversion_current}"
DATA_DIR_PREVIOUS="${PG_STORE_DIR}/postgres-previous"
DATA_DIR_OLD="${PG_STORE_DIR}/postgres-unknown"
PACKAGE_DIR_OLD=/var/vcap/packages/postgres-unknown
POSTGRES_UPGRADE_LOCK="$PG_STORE_DIR/POSTGRES_UPGRADE_LOCK"
pgversion_upgrade_from=postgres-unknown
if [ -f "${VERSION_FILE}" ]; then
pgversion_upgrade_from=$(cat ${VERSION_FILE})
DATA_DIR_OLD="${PG_STORE_DIR}/${pgversion_upgrade_from}"
PACKAGE_DIR_OLD=(/var/vcap/packages/${pgversion_upgrade_from%.*}*)
if [ ! -d "${PACKAGE_DIR_OLD}" ]; then
echo "Unable to find older postgres package to use for major upgrade. Upgrade to and older version first."
exit 1
fi
fi
<%
if !['rfc3339', 'deprecated'].include?(p('databases.logging.format.timestamp'))
raise "'#{p('databases.logging.format.timestamp')}' is not a valid timestamp format for the property 'databases.logging.format.timestamp'. Valid options are: 'rfc339' and 'deprecated'."
end
%>
RUN_DIR=/var/vcap/sys/run/postgres
LOG_DIR=/var/vcap/sys/log/postgres
LOG_FORMAT=<%= p("databases.logging.format.timestamp") %>
HOOK_LOG_OUT=${LOG_DIR}/hooks.stdout.log
HOOK_LOG_ERR=${LOG_DIR}/hooks.stderr.log
# external_pid_file in postgresql.conf takes care of
# overwriting $PIDFILE with actual DB server pid
PIDFILE="${RUN_DIR}/postgres.pid"
CONTROL_JOB_PIDFILE="${RUN_DIR}/postgresctl.pid"
PGJANITOR_PIDFILE="${RUN_DIR}/pg_janitor.pid"
HOST="0.0.0.0"
PORT="<%= p("databases.port") %>"
if [[ -n "${LD_LIBRARY_PATH:-}" ]]; then
LD_LIBRARY_PATH="${PACKAGE_DIR}/lib:${LD_LIBRARY_PATH}"
else
LD_LIBRARY_PATH="${PACKAGE_DIR}/lib"
fi
DATABASES=(<%= p("databases.databases", []).map{|d| d["name"]}.join(' ')%>)