this patch adds select box in the status page, enables to use
/etc/init.d/pgpool.
this requires sudo with no password for apache user on
/etc/init.d/pgpool to work.
for me this solves couple of problems:
* pgpool will run as postgres normally (and not as apache)
* the -n option doesn't work for me, and I need it
--
Asaf Ohaion
Lingnu Open Source Consulting Ltd.
http://www.lingnu.com
diff -uNr pgpoolAdmin-3.0.1/command.php pgpoolAdmin-3.0.1_initd_patch/command.php
--- pgpoolAdmin-3.0.1/command.php 2009-01-25 10:16:30.000000000 +0200
+++ pgpoolAdmin-3.0.1_initd_patch/command.php 2010-10-21 16:39:35.000000000 +0200
@@ -89,22 +89,27 @@
break;
case 'PCP_START_PGPOOL':
- $configOption = ' -f ' . _PGPOOL2_CONFIG_FILE . ' -F ' . _PGPOOL2_PASSWORD_FILE;
+ $configOption = ' -f ' . _PGPOOL2_CONFIG_FILE . ' -F ' . _PGPOOL2_PASSWORD_FILE;
- if(isPipe($num)) {
- $cmdOption = $configOption . $num . ' > /dev/null &';
- } else {
- $cmdOption = $configOption . $num . ' 2>&1 &';
- }
+ if(isPipe($num)) {
+ $cmdOption = $configOption . $num . ' > /dev/null &';
+ } else {
+ $cmdOption = $configOption . $num . ' 2>&1 &';
+ }
- /* we should not check pid file here.
- * let pgpool handle bogus pid file
+ /* we should not check pid file here.
+ * let pgpool handle bogus pid file
* if(DoesPgpoolPidExist()) {
* return array('FAIL'=> '');
* }
- */
- $cmd = _PGPOOL2_COMMAND . $cmdOption;
- //var_dump($cmd);exit;
+ */
+ if ($num == "initd") {
+ $cmd = "sudo /etc/init.d/pgpool start 2>&1";
+ } else {
+ $cmd = _PGPOOL2_COMMAND . $cmdOption;
+ }
+ // var_dump($cmd);exit;
+
$ret = exec($cmd, $output, $return_var);
if($return_var == 0) {
return array($pcpStatus[$return_var] => $output);
diff -uNr pgpoolAdmin-3.0.1/lang/en.lang.php pgpoolAdmin-3.0.1_initd_patch/lang/en.lang.php
--- pgpoolAdmin-3.0.1/lang/en.lang.php 2010-08-16 13:06:42.000000000 +0300
+++ pgpoolAdmin-3.0.1_initd_patch/lang/en.lang.php 2010-10-21 16:41:27.000000000 +0200
@@ -140,6 +140,7 @@
'strCmdN' => 'Don\'t run in daemon mode',
'strCmdPcpFile' => 'pcp.conf',
'strCmdPgpoolFile' => 'pgpool.conf',
+ 'strCmdSudoInitd' => 'Use sudo /etc/init.d/pgpool Instead',
'strColList' => 'Column list',
'strColName' => 'Column name of distributed key',
'strCommon' => 'Common',
diff -uNr pgpoolAdmin-3.0.1/lang/fr.lang.php pgpoolAdmin-3.0.1_initd_patch/lang/fr.lang.php
--- pgpoolAdmin-3.0.1/lang/fr.lang.php 2010-08-17 10:36:44.000000000 +0300
+++ pgpoolAdmin-3.0.1_initd_patch/lang/fr.lang.php 2010-10-21 16:41:27.000000000 +0200
@@ -140,6 +140,7 @@
'strCmdN' => 'Ne pas exécuter en mode démon',
'strCmdPcpFile' => 'pcp.conf',
'strCmdPgpoolFile' => 'pgpool.conf',
+ 'strCmdSudoInitd' => 'Use sudo /etc/init.d/pgpool Instead',
'strColList' => 'Liste de colonnes',
'strColName' => 'Nom de la colonne de la clé distribuée',
'strCommon' => 'Commun',
diff -uNr pgpoolAdmin-3.0.1/lang/ja.lang.php pgpoolAdmin-3.0.1_initd_patch/lang/ja.lang.php
--- pgpoolAdmin-3.0.1/lang/ja.lang.php 2010-08-16 13:06:42.000000000 +0300
+++ pgpoolAdmin-3.0.1_initd_patch/lang/ja.lang.php 2010-10-21 16:41:27.000000000 +0200
@@ -140,6 +140,7 @@
'strCmdN' => 'éãã¼ã¢ã³ã¢ã¼ã',
'strCmdPcpFile' => 'pcp.conf',
'strCmdPgpoolFile' => 'pgpool.conf',
+ 'strCmdSudoInitd' => 'Use sudo /etc/init.d/pgpool Instead',
'strColList' => 'ååãªã¹ã',
'strColName' => '忣ãã¼åå',
'strCommon' => 'å
±é',
diff -uNr pgpoolAdmin-3.0.1/status.php pgpoolAdmin-3.0.1_initd_patch/status.php
--- pgpoolAdmin-3.0.1/status.php 2010-07-22 08:17:47.000000000 +0300
+++ pgpoolAdmin-3.0.1_initd_patch/status.php 2010-10-21 16:39:35.000000000 +0200
@@ -65,26 +65,32 @@
case 'start':
$args = ' ';
- if(isset($_POST['c'])) {
- $args = $args . "-c ";
- }
- if(isset($_POST['D'])) {
- $args = $args . "-D ";
- }
- if(isset($_POST['d'])) {
- $args = $args . "-d ";
- }
- if(isset($_POST['n'])) {
- $pgpoolLog = _PGPOOL2_LOG_FILE;
- if($pgpoolLog == '') {
- $logDir = readLogDir();
- $pgpoolLog = "$logDir/pgpool.log";
- }
- if(isPipe($pgpoolLog))
- $args = "$args -n 2>&1 $pgpoolLog ";
- else
- $args = "$args -n > $pgpoolLog ";
- }
+ if(isset($_POST['i'])) // use /etc/init.d/pgpool
+ {
+ $args = "initd";
+ } else
+ {
+ if(isset($_POST['c'])) {
+ $args = $args . "-c ";
+ }
+ if(isset($_POST['D'])) {
+ $args = $args . "-D ";
+ }
+ if(isset($_POST['d'])) {
+ $args = $args . "-d ";
+ }
+ if(isset($_POST['n'])) {
+ $pgpoolLog = _PGPOOL2_LOG_FILE;
+ if($pgpoolLog == '') {
+ $logDir = readLogDir();
+ $pgpoolLog = "$logDir/pgpool.log";
+ }
+ if(isPipe($pgpoolLog))
+ $args = "$args -n 2>&1 $pgpoolLog ";
+ else
+ $args = "$args -n > $pgpoolLog ";
+ }
+ }
$ret = execPcp('PCP_START_PGPOOL', $args);
if(!array_key_exists('SUCCESS', $ret)) {
$tpl->assign('pgpoolStatus', 'pgpool start failed.');
diff -uNr pgpoolAdmin-3.0.1/templates/status.tpl pgpoolAdmin-3.0.1_initd_patch/templates/status.tpl
--- pgpoolAdmin-3.0.1/templates/status.tpl 2010-07-22 08:17:48.000000000 +0300
+++ pgpoolAdmin-3.0.1_initd_patch/templates/status.tpl 2010-10-21 16:41:07.000000000 +0200
@@ -237,6 +237,13 @@
<tr><td>{$message.strCmdPcpFile|escape}(-F)</td>
<td>{$pcpConf|escape}</td>
</tr>
+ <tr><td>{$message.strCmdSudoInitd|escape}</td>
+ {if $i == 1}
+ <td><input type="checkbox" name="i" checked="checked" /></td>
+ {else}
+ <td><input type="checkbox" name="i" /></td>
+ {/if}
+ </tr>
</tbody>
</table>
{else}
_______________________________________________
Pgpool-hackers mailing list
[email protected]
http://pgfoundry.org/mailman/listinfo/pgpool-hackers