From 8c7b2cd5f6d9efb59568382cd8b6e88d9be517bb Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Thu, 19 Mar 2015 12:53:28 +0100 Subject: init: add PGSTARTTIMEOUT config env variable * postgresql.init.in (PGSTARTTIMEOUT): New variable. (start): Use postgresql-ctl and respect PGSTARTTIMEOUT. * postgresql.service.in: Better document the timeouts. (PGSTARTTIMEOUT): New env variable. (ExecStart): Respect PGSTARTTIMEOUT. * NEWS: Document. --- postgresql.init.in | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'postgresql.init.in') 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 ] -- cgit