- fix pgpool-ha does not work well with multiple 'logdir' entries,
authorUser tanida <tanida at pgfoundry.org>
Mon, 18 Jun 2007 10:21:09 +0000 (10:21 +0000)
committerUser tanida <tanida at pgfoundry.org>
Mon, 18 Jun 2007 10:21:09 +0000 (10:21 +0000)
  even one of them is commented by #.
- Add support for pcp.conf and pool_hba.conf. It means pgpool-ha
  now works well with pgpool 3.2+ and pgpool-II.
- Add configuration parameter
  -pgpoolconf , path to pgpool.conf.
  -pbaconf , path to pool_hba.conf.
  -pcpconf , path to pcp.conf.
  -logfile ,  path to debug log output.

src/pgpool.in

index c57df2e84fcffb66efbaca9d69b4a26f7cf7d73f..769a543dab307c73bbd6cb3e8bea7e7ab0629abe 100755 (executable)
@@ -40,14 +40,50 @@ check_pid () {
 PATH=/bin:/usr/bin:/sbin:/usr/sbin
 export PATH
 PGP_CONF=`@_PGPOOL_@ -h 2>&1 | grep default | sed -e 's/  config_file default path: //g'`
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+export PATH
+if [ "x$OCF_RESKEY_pgpoolconf" = 'x' ]; then
+        PGP_CONF=`@_PGPOOL_@ -h 2>&1 | grep " config_file default" | sed -e 's/  config_file default path: //g'`
+else
+        PGP_CONF=$OCF_RESKEY_pgpoolconf
+fi
+if [ "x$OCF_RESKEY_pcpconf" = 'x' ]; then
+        PCP_CONF=`@_PGPOOL_@ -h 2>&1 | grep " pcp_config_file default" | sed -e 's/  pcp_config_file default path: //g'`
+else
+        PCP_CONF=$OCF_RESKEY_pcpconf
+fi
+if [ "x$OCF_RESKEY_hbaconf" = 'x' ]; then
+        HBA_CONF=`@_PGPOOL_@ -h 2>&1 | grep  " hba_file default" | sed -e 's/  hba_file default path: //g'`
+else
+        HBA_CONF=$OCF_RESKEY_hbaconf
+fi
+if [ "x$OCF_RESKEY_logfile" != 'x' ]; then
+        LOGFILE=$OCF_RESKEY_logfile
+fi
+
+echo $PGP_CONF
 
 PGPOOL="@_PGPOOL_@ -f $PGP_CONF" 
 PGPOOL_START_ARG=""
+
+if [ "x$HBA_CONF" != 'x' ];then
+        PGPOOL="$PGPOOL -a $HBA_CONF"
+fi
+
+if [ "x$PCP_CONF" != 'x' ];then
+        PGPOOL="$PGPOOL -F $PCP_CONF"
+fi
+
+if [ "x$LOGFILE" != 'x' ];then
+        PGPOOL="nohup $PGPOOL"
+        PGPOOL_START_ARG="$PGPOOL_START_ARG -d -n >>$LOGFILE 2>&1 &"
+fi
+
 PGPOOL_STOP_ARG=" stop"
 PGPOOL_FORCE_STOP_ARG=" -m i $PGPOOL_STOP_ARG"
 PGPOOL_MONITOR=@_PGPOOL_@.monitor 
 PGPOOL_MONITOR_ARGS=--conf=$PGP_CONF localhost >/dev/null 2>&1
-PGPOOL_PID=`grep logdir $PGP_CONF | tr -d "''=" | awk '{print $2."/pgpool.pid"}'`
+PGPOOL_PID=`grep  -P '^[^#]*logdir' $PGP_CONF | tr -d "''=" | awk '{print $2."/pgpool.pid"}'`
 
 # Source function library.
 . /etc/rc.d/init.d/functions
@@ -124,6 +160,35 @@ cat <<EOF
     </longdesc>
     <shortdesc lang="en">pgpool server control.</shortdesc>
     <parameters>
+      <parameter name="pgpoolconf" unique="0" required="0">
+      <longdesc lang="en">
+        Path to pgpool.conf
+      </longdesc>
+      <shortdesc lang="en">pgpool.conf path</shortdesc>
+      <content type="string" default="$PGP_CONF" />
+    </parameter>
+    <parameter name="pcpconf" unique="0" required="0">
+      <longdesc lang="en">
+        Path to pcp.conf. pgpool-II only.
+      </longdesc>
+      <shortdesc lang="en">pcp.conf</shortdesc>
+      <content type="string" default="$PCP_CONF" />
+    </parameter>
+    <parameter name="hbaconf" unique="0" required="0">
+      <longdesc lang="en">
+         Path to pool_hba.conf. requires pgpool > 3.2 only.
+      </longdesc>
+      <shortdesc lang="en">pool_hba.conf</shortdesc>
+      <content type="string" default="$HBA_CONF" />
+    </parameter>
+
+    <parameter name="logfile" unique="0" required="0">
+      <longdesc lang="en">
+         Path to output logfile . logfile contains debuglog. if this entry is empty , log output is depends on pgpool.
+      </longdesc>
+      <shortdesc lang="en">logfile</shortdesc>
+      <content type="string" default="" />
+    </parameter>
   </parameters>
   <actions>
     <action name="start"   timeout="20" />
@@ -143,4 +208,5 @@ EOF
        exit 1
 esac
 
-exit 0
+
+lexit 0