[Pkg-postgresql-public] Bug#736532: [postgres-xc] gtm proxy support in init script

Tim Sattarov stimur at gmail.com
Fri Jan 24 16:59:59 UTC 2014


Package: postgres-xc
Version: 1.1-2
Severity: normal
Tags: patch

--- Please enter the report below this line. ---

Hello,

Original init script included into the package does not support gtm proxy.

Please find below my suggested patch for init script to handle that
additional component of postgres-xc:


--- /etc/init.d/postgres-xc     2013-08-20 07:29:54.000000000 -0400
+++ ./postgres-xc       2014-01-24 11:37:20.185485456 -0500
@@ -33,6 +33,10 @@
 {
     status=0
     case "$1" in
+        gtm_proxy)
+            pidfile=gtm_proxy.pid
+            sleep 2
+            ;;
         gtm)
             pidfile=gtm.pid
             sleep 2
@@ -40,7 +44,7 @@
         postgres)
             pidfile=postmaster.pid
             confport=$(grep -si '^port *=' $PGXC_DATA/$2/postgresql.conf |
-               cut -f2 -d= | sed -e 's/#.*$//' -e 's/ //g')
+                cut -f2 -d= | sed -e 's/#.*$//' -e 's/ //g')
             port=${confport:=5432}

             # wait for server to come up, but no more than 10 seconds
@@ -63,6 +67,7 @@
             [ "`ps h -o comm -p $PID`" != $1 ] && status=1
         fi
     else
+#       echo $PGXC_DATA/$2/$pidfile is not readable
         status=1
     fi
     return 0
@@ -77,15 +82,24 @@
         $FAST_STOP &&
             STOP_MODE="-mf"
     }
-    for TYPE in datanode coordinator gtm; do
+    SEQUENCE="gtm gtm_proxy coordinator datanode"
+    [ "$ACTION" = "stop" ] && SEQUENCE="datanode coordinator gtm_proxy gtm"
+    for TYPE in $SEQUENCE; do
         case $TYPE in
             gtm)
             PG_CTL=gtm_ctl
             PG_START=gtm
+            EXTRA_OPTS=''
+            ;;
+            gtm_proxy)
+            PG_CTL=gtm_ctl
+            PG_START=gtm_proxy
+            EXTRA_OPTS=''
             ;;
             coordinator|datanode)
             PG_CTL=pg_ctl
             PG_START=postgres
+            EXTRA_OPTS=''
             ;;
         esac
         log_daemon_msg "$2 Postgres-XC ${TYPE}"
@@ -94,24 +108,37 @@
                 if [ "$ACTION" = "reload" ] && [ "$TYPE" = "gtm" ]; then
                     ACTION="restart"
                 fi
+                if [ "$ACTION" = "reload" ] && [ "$TYPE" = "gtm_proxy" ];
then
+                    ACTION="restart"
+                fi
                 [ "$ACTION" = "stop" ] &&
                 check_if_running $PG_START $NODE stop
                 if [ $status -eq 1 ]; then
                     log_progress_msg "$NODE is not running"
                 else
-                    ERRMSG=$(start-stop-daemon -c postgres-xc \
-                               -Sx /usr/bin/$PG_CTL  -- $ACTION $STOP_MODE
\
-                               -D $PGXC_DATA/$NODE -Z $TYPE \
-                               -l $PGXC_LOG/datanode.log
-                       STATUS=$?
-                       if $FAST_STOP && [ $STATUS -gt 0 ] &&
-                               [ "$ACTION" = "stop" ]; then
-                                       STATUS=0
-                                       start-stop-daemon -c postgres-xc \
-                                       -Sx /usr/bin/$PG_CTL  -- stop -mi \
-                                       -D $PGXC_DATA/$NODE -Z $TYPE \
-                                       -l $PGXC_LOG/datanode.log ||
STATUS=$?
-                       fi)
+                if [ "$TYPE" = "gtm_proxy" ] ; then EXTRA_OPTS="-o -D
$PGXC_DATA/$NODE"; fi
+                    ERRMSG=$(if [ "$TYPE" = "gtm_proxy" ] ; then {
+                                start-stop-daemon -c postgres-xc \
+                                -Sx /usr/bin/$PG_CTL  -- $ACTION
$STOP_MODE \
+                                -D $PGXC_DATA/$NODE -Z $TYPE \
+                                -l $PGXC_LOG/datanode.log -o "-D
$PGXC_DATA/$NODE"
+                                }
+                                else {
+                                start-stop-daemon -c postgres-xc \
+                                -Sx /usr/bin/$PG_CTL  -- $ACTION
$STOP_MODE \
+                                -D $PGXC_DATA/$NODE -Z $TYPE \
+                                -l $PGXC_LOG/datanode.log
+                                }
+                                fi
+                STATUS=$?
+                        if $FAST_STOP && [ $STATUS -gt 0 ] &&
+                                [ "$ACTION" = "stop" ]; then
+                                        STATUS=0
+                                        start-stop-daemon -c postgres-xc \
+                                        -Sx /usr/bin/$PG_CTL  -- stop -mi \
+                                        -D $PGXC_DATA/$NODE -Z $TYPE \
+                                        -l $PGXC_LOG/datanode.log ||
STATUS=$?
+                        fi)
                     REPORT=$NODE
                     [ "$ACTION" = "status" ] && REPORT=$ERRMSG
                     log_progress_msg "$REPORT"
@@ -153,4 +180,3 @@
 esac

 exit 0
-


Thanks
Tim

--- System information. ---
Architecture: amd64
Kernel:       Linux 3.11-2-amd64

Debian Release: jessie%2Fsid
  800 unstable        http.us.debian.org
  800 unstable        deb-multimedia.org
  500 stable          dl.google.com
    1 experimental    http.us.debian.org

--- Package information. ---
Depends                      (Version) | Installed
======================================- -================
libc6                        (>= 2.16) |
libcomerr2                   (>= 1.01) |
libgssapi-krb5-2       (>= 1.10 dfsg~) |
libkrb5-3              (>= 1.6.dfsg.2) |
libldap-2.4-2               (>= 2.4.7) |
libpam0g                 (>= 0.99.7.1) |
libpq5                       (>= 9.1~) |
libssl1.0.0                 (>= 1.0.0) |
libxml2                     (>= 2.7.4) |
zlib1g                    (>= 1:1.1.4) |
postgres-xc-client                     |
adduser                                |
ssl-cert                   (>= 1.0.11) |
logrotate                              |


Package's Recommends field is empty.

Package's Suggests field is empty.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-postgresql-public/attachments/20140124/203487ef/attachment.html>


More information about the Pkg-postgresql-public mailing list