Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F1841578
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
13 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/rgmanager/src/resources/postgres-8.metadata b/rgmanager/src/resources/postgres-8.metadata
index 1af8e8453..7b05d31bd 100644
--- a/rgmanager/src/resources/postgres-8.metadata
+++ b/rgmanager/src/resources/postgres-8.metadata
@@ -1,97 +1,97 @@
<?xml version="1.0"?>
<resource-agent version="rgmanager 2.0" name="postgres-8">
<version>1.0</version>
<longdesc lang="en">
This defines an instance of PostgreSQL server
</longdesc>
<shortdesc lang="en">
Defines a PostgreSQL server
</shortdesc>
<parameters>
<parameter name="name" primary="1">
<longdesc lang="en">
Specifies a service name for logging and other purposes
</longdesc>
<shortdesc lang="en">
Name
</shortdesc>
<content type="string"/>
</parameter>
<parameter name="config_file">
<longdesc lang="en">
Define absolute path to configuration file
</longdesc>
<shortdesc lang="en">
Config File
</shortdesc>
<content type="string" default="/var/lib/pgsql/data/postgresql.conf"/>
</parameter>
<parameter name="postmaster_user">
<longdesc lang="en">
User who runs the database server because it can't be
run by root.
</longdesc>
<shortdesc lang="en">
User who runs the database server
</shortdesc>
<content type="string" default="postgres" />
</parameter>
<parameter name="postmaster_options">
<longdesc lang="en">
Other command-line options for postmaster
</longdesc>
<shortdesc lang="en">
Other command-line options for postmaster
</shortdesc>
<content type="string" default="-D /var/lib/pgsql/data"/>
</parameter>
<parameter name="shutdown_wait">
<longdesc lang="en">
Wait X seconds for correct end of service shutdown.
This option is ignored in current release.
</longdesc>
<shortdesc lang="en">
Wait X seconds for correct end of service shutdown
This option is ignored in current release.
</shortdesc>
<content type="integer" />
</parameter>
<parameter name="service_name" inherit="service%name">
<longdesc lang="en">
Inherit the service name. We need to know
the service name in order to determine file
systems and IPs for this service.
</longdesc>
<shortdesc lang="en">
Inherit the service name.
</shortdesc>
<content type="string"/>
</parameter>
</parameters>
<actions>
- <action name="start" timeout="0"/>
- <action name="stop" timeout="0"/>
+ <action name="start" timeout="30"/>
+ <action name="stop" timeout="30"/>
<!-- Checks to see if it''s mounted in the right place -->
<action name="status" interval="1m" timeout="10"/>
<action name="monitor" interval="1m" timeout="10"/>
<!-- Checks to see if we can read from the mountpoint -->
<action name="status" depth="10" timeout="30" interval="5m"/>
<action name="monitor" depth="10" timeout="30" interval="5m"/>
<action name="meta-data" timeout="0"/>
<action name="validate-all" timeout="0"/>
</actions>
<special tag="rgmanager">
</special>
</resource-agent>
diff --git a/rgmanager/src/resources/postgres-8.sh b/rgmanager/src/resources/postgres-8.sh
index 5f96b0fd7..023a5e5a1 100755
--- a/rgmanager/src/resources/postgres-8.sh
+++ b/rgmanager/src/resources/postgres-8.sh
@@ -1,232 +1,233 @@
#!/bin/bash
#
# Copyright (C) 1997-2003 Sistina Software, Inc. All rights reserved.
# Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
export LC_ALL=C
export LANG=C
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
. $(dirname $0)/ocf-shellfuncs
. $(dirname $0)/utils/config-utils.sh
. $(dirname $0)/utils/messages.sh
. $(dirname $0)/utils/ra-skelet.sh
declare PSQL_POSTMASTER="/usr/bin/postmaster"
declare PSQL_CTL="/usr/bin/pg_ctl"
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_stop_timeout="15"
declare PSQL_wait_after_start="2"
verify_all()
{
clog_service_verify $CLOG_INIT
if [ -z "$OCF_RESKEY_name" ]; then
clog_service_verify $CLOG_FAILED "Invalid Name Of Service"
return $OCF_ERR_ARGS
fi
if [ -z "$OCF_RESKEY_service_name" ]; then
clog_service_verify $CLOG_FAILED_NOT_CHILD
return $OCF_ERR_ARGS
fi
if [ -z "$OCF_RESKEY_config_file" ]; then
clog_check_file_exist $CLOG_FAILED_INVALID "$OCF_RESKEY_config_file"
clog_service_verify $CLOG_FAILED
return $OCF_ERR_ARGS
fi
if [ ! -r "$OCF_RESKEY_config_file" ]; then
clog_check_file_exist $CLOG_FAILED_NOT_READABLE $OCF_RESKEY_config_file
clog_service_verify $CLOG_FAILED
return $OCF_ERR_ARGS
fi
if [ -z "$OCF_RESKEY_postmaster_user" ]; then
clog_servicer_verify $CLOG_FAILED "Invalid User"
return $OCF_ERR_ARGS
fi
clog_service_verify $CLOG_SUCCEED
return 0
}
generate_config_file()
{
declare original_file="$1"
declare generated_file="$2"
declare ip_addressess="$3"
declare ip_comma="";
if [ -f "$generated_file" ]; then
sha1_verify "$generated_file"
if [ $? -ne 0 ]; then
clog_check_sha1 $CLOG_FAILED
return 0
fi
fi
clog_generate_config $CLOG_INIT "$original_file" "$generated_file"
declare x=1
for i in $ip_addressess; do
i=`echo $i | sed -e 's/\/.*$//'`
if [ $x -eq 1 ]; then
x=0
ip_comma=$i
else
ip_comma=$ip_comma,$i
fi
done
generate_configTemplate "$generated_file" "$1"
echo "external_pid_file = '$PSQL_pid_file'" >> "$generated_file"
echo "listen_addresses = '$ip_comma'" >> "$generated_file"
echo >> "$generated_file"
sed 's/^[[:space:]]*external_pid_file/### external_pid_file/i;s/^[[:space:]]*listen_addresses/### listen_addresses/i' < "$original_file" >> "$generated_file"
sha1_addToFile "$generated_file"
clog_generate_config $CLOG_SUCCEED "$original_file" "$generated_file"
return 0;
}
start()
{
declare pguser_group
clog_service_start $CLOG_INIT
create_pid_directory
create_conf_directory "$PSQL_conf_dir"
check_pid_file "$PSQL_pid_file"
if [ $? -ne 0 ]; then
clog_check_pid $CLOG_FAILED "$PSQL_pid_file"
clog_service_start $CLOG_FAILED
return $OCF_ERR_GENERIC
fi
#
# Create an empty PID file for the postgres user and
# change it to be owned by the postgres user so that
# postmaster doesn't complain.
#
pguser_group=`groups $OCF_RESKEY_postmaster_user | cut -f1 -d ' '`
touch $PSQL_pid_file
chown $OCF_RESKEY_postmaster_user.$pguser_group $PSQL_pid_file
clog_looking_for $CLOG_INIT "IP Addresses"
get_service_ip_keys "$OCF_RESKEY_service_name"
ip_addresses=`build_ip_list`
if [ -z "$ip_addresses" ]; then
clog_looking_for $CLOG_FAILED_NOT_FOUND "IP Addresses"
return $OCF_ERR_GENERIC
fi
clog_looking_for $CLOG_SUCCEED "IP Addresses"
generate_config_file "$OCF_RESKEY_config_file" "$PSQL_gen_config_file" "$ip_addresses"
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 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
if [ $? -ne 0 ]; then
clog_service_start $CLOG_FAILED
return $OCF_ERR_GENERIC
fi
clog_service_start $CLOG_SUCCEED
return 0;
}
stop()
{
clog_service_stop $CLOG_INIT
- ## Send -KILL signal immediately
- stop_generic_sigkill "$PSQL_pid_file" 0 "$PSQL_kill_timeout"
+ ## Send -INT to close connections and stop. -QUIT is used if -INT signal does not stop process.
+ stop_generic_sigkill "$PSQL_pid_file" "$PSQL_stop_timeout" "$PSQL_kill_timeout" "-INT"
if [ $? -ne 0 ]; then
clog_service_stop $CLOG_FAILED
return $OCF_ERR_GENERIC
fi
clog_service_stop $CLOG_SUCCEED
return 0;
}
status()
{
clog_service_status $CLOG_INIT
status_check_pid "$PSQL_pid_file"
if [ $? -ne 0 ]; then
clog_service_status $CLOG_FAILED "$PSQL_pid_file"
return $OCF_ERR_GENERIC
fi
clog_service_status $CLOG_SUCCEED
return 0
}
case $1 in
meta-data)
cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'`
exit 0
;;
validate-all)
verify_all
exit $?
;;
start)
verify_all && start
exit $?
;;
stop)
verify_all && stop
exit $?
;;
status|monitor)
verify_all
status
exit $?
;;
restart)
verify_all
stop
start
exit $?
;;
*)
echo "Usage: $0 {start|stop|status|monitor|restart|meta-data|validate-all}"
exit $OCF_ERR_UNIMPLEMENTED
;;
esac
diff --git a/rgmanager/src/resources/utils/ra-skelet.sh b/rgmanager/src/resources/utils/ra-skelet.sh
index d88a03340..cdee5c47c 100644
--- a/rgmanager/src/resources/utils/ra-skelet.sh
+++ b/rgmanager/src/resources/utils/ra-skelet.sh
@@ -1,147 +1,156 @@
#!/bin/bash
#
# Copyright (C) 1997-2003 Sistina Software, Inc. All rights reserved.
# Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
status_check_pid()
{
declare pid_file="$1"
if [ -z "$pid_file" ]; then
clog_check_file_exist $CLOG_FAILED_INVALID "$pid_file"
return $OCF_ERR_GENERIC
fi
if [ ! -e "$pid_file" ]; then
clog_check_file_exist $CLOG_FAILED "$pid_file"
return $OCF_NOT_RUNNING
fi
read pid < "$pid_file"
if [ -z "$pid" ]; then
return $OCF_ERR_GENERIC
fi
if [ ! -d /proc/$pid ]; then
return $OCF_ERR_GENERIC
fi
return 0
}
stop_generic()
{
declare pid_file="$1"
declare stop_timeout="$2"
+ declare stop_sig="$3"
declare pid;
declare count=0;
+ if [ -z "$stop_sig" ]; then
+ stop_sig="-TERM"
+ fi
+
if [ ! -e "$pid_file" ]; then
clog_check_file_exist $CLOG_FAILED_NOT_FOUND "$pid_file"
# In stop-after-stop situation there is no PID file but
# it will be nice to check for it in stop-after-start
# look at bug #449394
return 0
fi
if [ -z "$stop_timeout" ]; then
stop_timeout=20
fi
read pid < "$pid_file"
# @todo: PID file empty -> error?
if [ -z "$pid" ]; then
return 0;
fi
# @todo: PID is not running -> error?
if [ ! -d "/proc/$pid" ]; then
return 0;
fi
- kill -TERM "$pid"
+ kill $stop_sig "$pid"
if [ $? -ne 0 ]; then
return $OCF_ERR_GENERIC
fi
until [ `ps --pid "$pid" &> /dev/null; echo $?` = '1' ] || [ $count -gt $stop_timeout ]
do
sleep 1
let count=$count+1
done
if [ $count -gt $stop_timeout ]; then
clog_service_stop $CLOG_FAILED_NOT_STOPPED
return $OCF_ERR_GENERIC
fi
return 0;
}
stop_generic_sigkill() {
# Use stop_generic (kill -TERM) and if application did not stop
# correctly then use kill -QUIT and check if it was killed
declare pid_file="$1"
declare stop_timeout="$2"
declare kill_timeout="$3"
+ declare stop_sig="$4"
declare pid
-
+
+ if [ -z "$stop_sig" ]; then
+ stop_sig="-TERM"
+ fi
## If stop_timeout is equal to zero then we do not want
## to give -TERM signal at all.
if [ $stop_timeout -ne 0 ]; then
- stop_generic "$pid_file" "$stop_timeout"
+ stop_generic "$pid_file" "$stop_timeout" "$stop_sig"
if [ $? -eq 0 ]; then
return 0;
fi
fi
if [ ! -e "$pid_file" ]; then
clog_check_file_exist $CLOG_FAILED_NOT_FOUND "$pid_file"
# In stop-after-stop situation there is no PID file but
# it will be nice to check for it in stop-after-start
# look at bug #449394
return 0
fi
read pid < "$pid_file"
if [ -z "$pid" ]; then
return 0;
fi
if [ ! -d "/proc/$pid" ]; then
return 0;
fi
kill -QUIT "$pid"
if [ $? -ne 0 ]; then
return $OCF_GENERIC_ERROR
fi
sleep "$kill_timeout"
ps --pid "$pid" &> /dev/null
if [ $? -eq 0 ]; then
clog_service_stop $CLOG_FAILED_KILL
return $OCF_ERR_GENERIC
fi
clog_service_stop $CLOG_SUCCEED_KILL
return 0
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Nov 23, 6:09 AM (15 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1018282
Default Alt Text
(13 KB)
Attached To
Mode
rR Resource Agents
Attached
Detach File
Event Timeline
Log In to Comment