[pgbouncer] - Fix chkconfig line - Start pgbouncer in daemon mode, so that it won't log twice - to the same log

Devrim GÜNDÜZ devrim at fedoraproject.org
Fri Nov 2 12:03:46 UTC 2012


commit 14c9f8d646fda3c6a8173e88e7b2a3ad2587355b
Author: Devrim GUNDUZ <devrim at gunduz.org>
Date:   Fri Nov 2 13:59:45 2012 +0200

    - Fix chkconfig line
    - Start pgbouncer in daemon mode, so that it won't log twice
    - to the same log file.
    
    - Sleep 2 seconds before getting pid during start(), like
      we do in PostgreSQL init script, to avoid false positive  startup errors.

 pgbouncer.init |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/pgbouncer.init b/pgbouncer.init
index d45a4fe..5ed6c71 100644
--- a/pgbouncer.init
+++ b/pgbouncer.init
@@ -8,7 +8,17 @@
 # pidfile: /var/run/pgbouncer/pgbouncer.pid
 #
 # v2.0 Devrim GUNDUZ <devrim at gunduz.org>
-# - Adjust order of startup and kill
+# - Adjust order of startup and kill.
+#
+# v2.1 Devrim GUNDUZ <devrim at gunduz.org>
+# - Fix chkconfig line
+# - Start pgbouncer in daemon mode, so that it won't log twice 
+# - to the same log file.
+#
+# v2.2 Devrim GUNDUZ <devrim at gunduz.org>
+# - Sleep 2 seconds before getting pid during start(), like 
+#   we do in PostgreSQL init script, to avoid false positive
+#   startup errors.
 
 # Source function library.
 INITD=/etc/rc.d/init.d
@@ -50,7 +60,7 @@ start(){
 	if [ ! -e "$BOUNCERLOG" -a ! -h "$BOUNCERLOG" ]
 	then
 		touch "$BOUNCERLOG" || exit 1
-		chown postgres:postgres "$BOUNCERLOG"
+		chown pgbouncer:pgbouncer "$BOUNCERLOG"
 		chmod go-rwx "$BOUNCERLOG"
 		[ -x /usr/bin/chcon ] && /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$BOUNCERLOG" 2>/dev/null
 	fi
@@ -66,9 +76,10 @@ start(){
 
 	echo -n "$BOUNCER_START"
 	[ -d /var/run/${NAME} ] || mkdir /var/run/${NAME}
-	chown postgres: /var/run/${NAME}
+	chown pgbouncer:pgbouncer /var/run/${NAME}
 
-	$SU -l postgres -c "pgbouncer '$BOUNCERCONF' & " >> "$BOUNCERLOG" 2>&1 < /dev/null
+	$SU -l pgbouncer -c "pgbouncer -d '$BOUNCERCONF' & " >> "$BOUNCERLOG" 2>&1 < /dev/null
+	sleep 2
 	pid=`pidof -s pgbouncer`
         if [ $pid ]
         then
@@ -120,13 +131,13 @@ condstop(){
 }
 
 reload(){
-    $SU -l postgres -c "kill -HUP `cat /var/run/${NAME}/${NAME}.pid`" > /dev/null 2>&1 < /dev/null
+    $SU -l pgbouncer -c "kill -HUP `cat /var/run/${NAME}/${NAME}.pid`" > /dev/null 2>&1 < /dev/null
 }
 pause(){
-    $SU -l postgres -c "kill -USR1 `cat /var/run/${NAME}/${NAME}.pid`" > /dev/null 2>&1 < /dev/null
+    $SU -l pgbouncer -c "kill -USR1 `cat /var/run/${NAME}/${NAME}.pid`" > /dev/null 2>&1 < /dev/null
 }
 resum(){
-   $SU -l postgres -c "kill -USR2 `cat /var/run/${NAME}/${NAME}.pid`" > /dev/null 2>&1 < /dev/null
+   $SU -l pgbouncer -c "kill -USR2 `cat /var/run/${NAME}/${NAME}.pid`" > /dev/null 2>&1 < /dev/null
 }
 # See how we were called.
 case "$1" in


More information about the scm-commits mailing list