summaryrefslogtreecommitdiffstats
path: root/postgresql.init.in
diff options
context:
space:
mode:
Diffstat (limited to 'postgresql.init.in')
-rw-r--r--postgresql.init.in18
1 files changed, 14 insertions, 4 deletions
diff --git a/postgresql.init.in b/postgresql.init.in
index 70058d6..ca0909e 100644
--- a/postgresql.init.in
+++ b/postgresql.init.in
@@ -73,6 +73,7 @@ PG_OOM_ADJ=-17
export PGDATA
export PGPORT
+export PGSTARTTIMEOUT
lockfile="/var/lock/subsys/${NAME}"
@@ -111,13 +112,22 @@ start()
# is already running. We should probably 'status' first and start only if
# postmaster is down. This just unnecessarily wastes time and generates
# too much (false) rush in $PGLOG.
+ #
+ # The maximum waiting time PGSTARTTIMEOUT is set to 30 second to not hold
+ # the system too long. See `man pg_ctl & -w option`. This is not issue in
+ # case of systemd.
+
run_cmd_as_dbadmin \
- "$PGENGINE/postgres ${PGPORT+-o "-p $PGPORT"} \
- -D '$PGDATA' ${PGOPTS} &" \
+ "@libexecdir@/postgresql-ctl start -D ${PGDATA} -s \
+ -w -t ${PGSTARTTIMEOUT-30}" \
"$PGLOG" "$PGLOG"
- # TODO: parametrize
- sleep 2
+ if test $? -ne 0; then
+ failure "$PSQL_START"
+ echo
+ script_result=1
+ return
+ fi
pid=`head -n 1 "$PGDATA/postmaster.pid" 2>/dev/null`
if [ "x$pid" != x ]