Gitweb:
http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=ddb0cfbd344...
Commit: ddb0cfbd344395f63dce31794bb7eea3f7be1ce8
Parent: f5e510ffc9f762093d6d83b5d5876f50b892868a
Author: Ryan McCabe <rmccabe(a)redhat.com>
AuthorDate: Thu Mar 13 13:21:41 2014 -0400
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Thu Mar 13 13:21:41 2014 -0400
postgres-8.sh: Add "startup_wait" attribute
Add a "startup_wait" attribute that allows for enough time
for pg_ctl to detect a successful startup.
Patch from John Ruemker <jruemker(a)redhat.com>
Resolves: rhbz#1035023
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/src/resources/postgres-8.metadata | 10 ++++++++++
rgmanager/src/resources/postgres-8.sh | 15 ++++++++++-----
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/rgmanager/src/resources/postgres-8.metadata
b/rgmanager/src/resources/postgres-8.metadata
index 67c863e..b061fc5 100644
--- a/rgmanager/src/resources/postgres-8.metadata
+++ b/rgmanager/src/resources/postgres-8.metadata
@@ -63,6 +63,16 @@
<content type="number" />
</parameter>
+ <parameter name="startup_wait">
+ <longdesc lang="en">
+ Wait X seconds for correct end of service startup
+ </longdesc>
+ <shortdesc lang="en">
+ Wait X seconds for correct end of service startup.
+ </shortdesc>
+ <content type="number" default="10"/>
+ </parameter>
+
<parameter name="service_name" inherit="service%name">
<longdesc lang="en">
Inherit the service name. We need to know
diff --git a/rgmanager/src/resources/postgres-8.sh
b/rgmanager/src/resources/postgres-8.sh
index f99e32d..585da6a 100755
--- a/rgmanager/src/resources/postgres-8.sh
+++ b/rgmanager/src/resources/postgres-8.sh
@@ -38,7 +38,6 @@ declare PSQL_pid_file="`generate_name_for_pid_file`"
declare PSQL_conf_dir="`generate_name_for_conf_dir`"
declare PSQL_gen_config_file="$PSQL_conf_dir/postgresql.conf"
declare PSQL_kill_timeout="5"
-declare PSQL_wait_after_start="2"
verify_all()
{
@@ -122,6 +121,7 @@ start()
{
declare ccs_fd;
declare pguser_group
+ declare count=0
clog_service_start $CLOG_INIT
@@ -167,12 +167,17 @@ start()
su - "$OCF_RESKEY_postmaster_user" -c "$PSQL_POSTMASTER -c
config_file=\"$PSQL_gen_config_file\" \
$OCF_RESKEY_postmaster_options" &> /dev/null &
- # We need to sleep for a second to allow pg_ctl to detect that we've started.
- sleep $PSQL_wait_after_start
+ # We need to sleep briefly to allow pg_ctl to detect that we've started.
# We need to fetch "-D /path/to/pgsql/data" from
$OCF_RESKEY_postmaster_options
- su - "$OCF_RESKEY_postmaster_user" -c "$PSQL_CTL status
$OCF_RESKEY_postmaster_options" &> /dev/null
+ until [ "$count" -gt "$OCF_RESKEY_startup_wait" ] ||
+ [ `su - "$OCF_RESKEY_postmaster_user" -c \
+ "$PSQL_CTL status $OCF_RESKEY_postmaster_options" &> /dev/null; echo
$?` = '0' ]
+ do
+ sleep 1
+ let count=$count+1
+ done
- if [ $? -ne 0 ]; then
+ if [ "$count" -gt "$OCF_RESKEY_startup_wait" ]; then
clog_service_start $CLOG_FAILED
return $OCF_ERR_GENERIC
fi