summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS16
-rw-r--r--configure.ac2
-rw-r--r--postgresql-ctl.in11
-rw-r--r--postgresql.init.in68
4 files changed, 75 insertions, 22 deletions
diff --git a/NEWS b/NEWS
index d4dc148..d402ac2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,20 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-New in 3.1 version
+Bugfixes in 3.3 version
+
+* The PGPORT/PGOPTS/.. variables should be correctly forwarded down from
+ the initstcript into postgresql-ctl.
+
+* Initscript's 'start' function again reports success if daemon is already
+ running.
+
+New in 3.3 version
+
+* New option PGSTARTWAIT for sysvinit systems.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+New in 3.2 version
* The --new-systemd-unit option now cleans the recently created drop-in
directory if something goes wrong.
diff --git a/configure.ac b/configure.ac
index 7e7ae38..95368e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
# Use the MAJ.MIN[~SUFF]. Note that X.X > X.X~SUFF!
-AC_INIT([postgresql-setup], [3.2], [praiskup@redhat.com])
+AC_INIT([postgresql-setup], [3.3], [praiskup@redhat.com])
AC_CONFIG_AUX_DIR(auxdir)
config_aux_dir=auxdir
AC_SUBST([config_aux_dir])
diff --git a/postgresql-ctl.in b/postgresql-ctl.in
index ad18004..569e4d3 100644
--- a/postgresql-ctl.in
+++ b/postgresql-ctl.in
@@ -22,9 +22,10 @@
# such extension, not the server itself).
test -n "$PGSCLS" && source scl_source enable $PGSCLS
-port=()
-if test "$1" = "start" && test -n "$PGPORT"; then
- port=(-o "-p $PGPORT")
-fi
+opts=()
+test "$1" = "start" && test -n "$PGOPTS" && opts=(-o "$PGOPTS")
-exec @bindir@/pg_ctl "$@" "${port[@]}"
+# cleanup possibly empty PGPORT
+test -z "$PGPORT" && unset PGPORT
+
+exec @bindir@/pg_ctl "$@" "${opts[@]}"
diff --git a/postgresql.init.in b/postgresql.init.in
index 7fca5f3..a078c28 100644
--- a/postgresql.init.in
+++ b/postgresql.init.in
@@ -117,11 +117,26 @@ start()
# 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.
+ #
+ # PGSTARTWAIT turns on waiting for server to become fully ready to accept
+ # connection.
+
+ # clean the variable if not set to 1
+ test x1 != x"$PGSTARTWAIT" && PGSTARTWAIT=
+
+ # success if already started (pg_ctl -w could fail later)
+ status -p "$pidfile" postgres &>/dev/null && {
+ success "$PSQL_START"
+ echo
+ exit 0
+ }
run_cmd_as_dbadmin "\
- PGSCLS='${PGSCLS}' \
- @libexecdir@/postgresql-ctl start -D ${PGDATA} -s \
- -w -t ${PGSTARTTIMEOUT-30}" \
+ PGSCLS=$(printf %q "$PGSCLS") \
+ PGOPTS=$(printf %q "$PGOPTS") \
+ PGPORT=$(printf %q "$PGPORT") \
+ @libexecdir@/postgresql-ctl start -D $(printf %q "$PGDATA") -s \
+ ${PGSTARTWAIT:+-w -t ${PGSTARTTIMEOUT:-30}}" \
"$PGLOG" "$PGLOG"
if test $? -ne 0; then
@@ -131,18 +146,41 @@ start()
return
fi
- pid=`head -n 1 "$PGDATA/postmaster.pid" 2>/dev/null`
- if [ "x$pid" != x ]
- then
- success "$PSQL_START"
- touch "$lockfile"
- echo $pid > "$pidfile"
- echo
- else
- failure "$PSQL_START"
- echo
- script_result=1
- fi
+ # pg_ctl succeed, now recognize the pid number
+
+ pid=
+ if test x1 != x"$PGSTARTWAIT" ; then
+ # We don't wait for the full postgresql server start. In this case,
+ # wait for pidfile creation only. This should take _very_ short time in
+ # most cases but on highly overloaded machines - several seconds may
+ # not be enough. See rhbz#800534 and rhbz#1188942 for more info.
+ # Original waiting implementation by Jozef MlĂ­ch.
+
+ decounter=${PGSTARTTIMEOUT:-30}
+ while test "$decounter" -ge 0; do
+ pid=$(head -n 1 "$PGDATA/postmaster.pid" 2>/dev/null)
+
+ test "x$pid" != x && break
+
+ # pidfile does not exist yet, wait a sec more
+ decounter=$(( decounter - 1 ))
+ sleep 1
+ done
+ else
+ # pg_ctl -w succeed, pidfile must exist if everything is OK
+ pid=$(head -n 1 "$PGDATA/postmaster.pid" 2>/dev/null)
+ fi
+
+ if test "x$pid" != x; then
+ success "$PSQL_START"
+ touch "$lockfile"
+ echo "$pid" > "$pidfile"
+ echo
+ else
+ failure "$PSQL_START"
+ echo
+ script_result=1
+ fi
}
stop()