#!/bin/sh # # pgbouncer OCF RA. # # by Fabien Foglia 01/02/2008 # ####################################################################### # Initialization: . ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs ####################################################################### meta_data() { cat < 1.0 This is a Pgbouncer Resource Agent. Pgbouncer resource agent END } ####################################################################### pgbouncer_usage() { cat <= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions pgbouncer_start() { if [ "$START" != "1" -a "$1" != "stop" ]; then [ "$VERBOSE" != yes ] && log_warning_msg "Not starting pgbouncer - edit /etc/default/pgbouncer and change START to be 1."; return $OCF_ERR_UNIMPLEMENTED; fi start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null \ || return $OCF_NOT_RUNNING; start-stop-daemon --start --quiet --exec $DAEMON -- \ $DAEMON_ARGS \ || return $OCF_NOT_RUNNING; # Add code here, if necessary, that waits for the process to be ready # to handle requests from services started subsequently which depend # on this one. As a last resort, sleep for some time. return $OCF_SUCCESS; } pgbouncer_stop() { if [ -f $PIDFILE ]; then pid=`cat $PIDFILE` else return 7 fi kill $pid; return 0; } pgbouncer_monitor() { if [ -f $PIDFILE ]; then pid=`cat $PIDFILE` fi if [ ! -z $pid ]; then kill -0 $pid if [ $? = 0 ]; then return $OCF_SUCCESS fi fi return $OCF_NOT_RUNNING } case $__OCF_ACTION in meta-data) meta_data exit $OCF_SUCCESS ;; start) pgbouncer_start;; stop) pgbouncer_stop;; monitor) pgbouncer_monitor;; usage|help) pgbouncer_usage exit $OCF_SUCCESS ;; *) pgbouncer_usage exit $OCF_ERR_UNIMPLEMENTED ;; esac rc=$? ocf_log debug "${OCF_RESOURCE_INSTANCE} $__OCF_ACTION : $rc" exit $rc