added option to start ctdb under valgrind
authorAndrew Tridgell <tridge@samba.org>
Fri, 4 Jul 2008 06:58:14 +0000 (16:58 +1000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 4 Jul 2008 06:58:14 +0000 (16:58 +1000)
Just add CTDB_VALGRIND=yes in /etc/sysconfig/ctdb, and look at the
logs in /var/log/ctdb_valgrind.*

config/ctdb.init

index 88ecc7745711a822241a798c57e373cfe5b45c1e..760d6de5e92f616e4db777eb6e00e87f0d193f49 100755 (executable)
@@ -73,7 +73,9 @@ CTDB_OPTIONS="$CTDB_OPTIONS --reclock=$CTDB_RECOVERY_LOCK"
        CTDB_OPTIONS="$CTDB_OPTIONS --no-lmaster"
 }
 
-if [ -x /sbin/startproc ]; then
+if [ "$CTDB_VALGRIND" = "yes" ]; then
+    init_style="valgrind"
+else if [ -x /sbin/startproc ]; then
     init_style="suse"
 else if [ -x /sbin/start-stop-daemon ]; then
        init_style="ubuntu"
@@ -81,6 +83,7 @@ else if [ -x /sbin/start-stop-daemon ]; then
        init_style="redhat"
     fi
 fi
+fi
 
 start() {
         killall -q ctdbd
@@ -100,6 +103,10 @@ start() {
        done
 
        case $init_style in
+           valgrind)
+               valgrind -q --log-file=/var/log/ctdb_valgrind /usr/sbin/ctdbd --nosetsched $CTDB_OPTIONS 
+               RETVAL=0
+               ;;
            suse)
                startproc /usr/sbin/ctdbd $CTDB_OPTIONS
                rc_status -v
@@ -134,6 +141,11 @@ stop() {
        ctdb shutdown
        RETVAL=$?
        count=0
+       if [ "$init_style" = "valgrind" ]; then
+           # very crude method
+           sleep 2
+           pkill -9 -f valgrind
+       fi
        while killall -q -0 ctdbd; do
            sleep 1
            count=`expr $count + 1`