From 7f6f3984a984e9128858f51468b034aa15609370 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Wed, 26 Jan 2011 12:52:32 +0000 Subject: [PATCH] Remove stale sockets and other files too before startup, SB #77357. --- org.glite.lb.harvester/config/startup | 15 ++++++++++++--- org.glite.lb.logger/config/startup | 16 ++++++++++++---- org.glite.lb.server/config/startup | 19 +++++++++++++------ 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/org.glite.lb.harvester/config/startup b/org.glite.lb.harvester/config/startup index 2169d4f..f04348c 100755 --- a/org.glite.lb.harvester/config/startup +++ b/org.glite.lb.harvester/config/startup @@ -44,6 +44,8 @@ if [ -n "$GLITE_LB_HARVESTER_CONFIG" ]; then fi [ -n "$GLITE_LB_HARVESTER_DBCS" ] && conf="$conf -m $GLITE_LB_HARVESTER_DBCS" +HARVESTER_NOTIFSFILE=/var/tmp/notifs.txt + unset creds port log4c [ -n "$GLITE_HOST_CERT" -a -n "$GLITE_HOST_KEY" ] && @@ -61,13 +63,20 @@ start_daemon() local name="$1" local pidfile="$2" local cmd="$3" + local stale="$4" if [ -f "$pidfile" ]; then if ps p `cat $pidfile` >/dev/null 2>&1; then return 0 fi - echo -n "Warning: stalled $pidfile for $name" + echo "Warning: stale $pidfile for $name" rm -f "$pidfile" + if [ -n "$stale" ]; then + for file in $stale; do + echo "Warning: stale $file for $name" + rm -f "$file" + done + fi fi echo -n "Starting $name ..." su - $GLITE_USER -c "$log4c $cmd" && echo " done" || echo " FAILED" @@ -111,7 +120,7 @@ status_daemon() if ps p $pid >/dev/null 2>&1; then echo "$name running as $pid" else - echo "$name not running (stalled pidfile)" + echo "$name not running (stale pidfile)" return 1 fi else @@ -143,7 +152,7 @@ start() start_daemon glite-lb-harvester "$pidfile" "$GLITE_LOCATION/bin/glite-lb-harvester \ $creds $conf -i $pidfile -d $level $port --daemon\ - $GLITE_LB_HARVESTER_OTHER_OPTIONS" + $GLITE_LB_HARVESTER_OTHER_OPTIONS" "$HARVESTER_NOTIFSFILE" } stop() diff --git a/org.glite.lb.logger/config/startup b/org.glite.lb.logger/config/startup index 5c3139d..7a70366 100755 --- a/org.glite.lb.logger/config/startup +++ b/org.glite.lb.logger/config/startup @@ -30,6 +30,7 @@ GLITE_LOCATION_VAR=${GLITE_LOCATION_VAR:-$GLITE_LOCATION/var} LL_PIDFILE=${LL_PIDFILE:-$GLITE_LOCATION_VAR/glite-lb-logd.pid} IL_PIDFILE=${IL_PIDFILE:-$GLITE_LOCATION_VAR/glite-lb-interlogd.pid} +IL_SOCKFILE=/tmp/interlogger.sock unset creds port log4c @@ -38,13 +39,20 @@ start_daemon() local name="$1" local pidfile="$2" local cmd="$3" + local stale="$4" if [ -f "$pidfile" ]; then if ps p `cat $pidfile` >/dev/null 2>&1; then return 0 fi - echo -n "Warning: stalled $pidfile for $name" + echo "Warning: stale $pidfile for $name" rm -f "$pidfile" + if [ -n "$stale" ]; then + for file in $stale; do + echo "Warning: stale $file for $name" + rm -f "$file" + done + fi fi echo -n "Starting $name ..." su - $GLITE_USER -c "$log4c $cmd" && echo " done" || echo " FAILED" @@ -60,7 +68,7 @@ status_daemon() if ps p $pid >/dev/null 2>&1; then echo "$name running as $pid" else - echo "$name not running (stalled pidfile)" + echo "$name not running (stale pidfile)" return 1 fi else @@ -118,7 +126,7 @@ start() -i $LL_PIDFILE $creds $port $sock $fprefix" start_daemon "glite-lb-interlogd" "$IL_PIDFILE" "$GLITE_LOCATION/bin/glite-lb-interlogd \ - -i $IL_PIDFILE $creds $sock $fprefix" + -i $IL_PIDFILE $creds $sock $fprefix" "$IL_SOCKFILE" } killwait() @@ -150,7 +158,7 @@ stop() if netstat -an --inet --inet6 | grep "^tcp .* \(::\|0.0.0.0\):${GLITE_LB_LOGGER_PORT:-9002} .*LISTEN" >/dev/null 2>&1 ;then killall -9 glite-lb-logd fi - if netstat -an --unix | grep "^unix .* LISTEN.* ${GLITE_LB_IL_SOCK:-/tmp/interlogger.sock}$" >/dev/null 2>&1 ;then + if netstat -an --unix | grep "^unix .* LISTEN.* ${GLITE_LB_IL_SOCK:-$IL_SOCKFILE}$" >/dev/null 2>&1 ;then killall -9 glite-lb-interlogd fi } diff --git a/org.glite.lb.server/config/startup b/org.glite.lb.server/config/startup index a47cb8a..e1afc9f 100755 --- a/org.glite.lb.server/config/startup +++ b/org.glite.lb.server/config/startup @@ -49,13 +49,20 @@ start_daemon() local name="$1" local pidfile="$2" local cmd="$3" + local stale="$4" if [ -f "$pidfile" ]; then - if ps p `cat $pidfile` >/dev/null 2>&2; then + if ps p `cat $pidfile` >/dev/null 2>&1; then return 0 fi - echo -n "Warning: stalled $pidfile for $name" + echo "Warning: stale $pidfile for $name" rm -f "$pidfile" + if [ -n "$stale" ]; then + for file in $stale; do + echo "Warning: stale $file for $name" + rm -f "$file" + done + fi fi echo -n "Starting $name ..." su - $GLITE_USER -c "$log4c $cmd" && echo " done" || echo " FAILED" @@ -99,7 +106,7 @@ status_daemon() if ps p $pid >/dev/null 2>&1; then echo "$name running as $pid" else - echo "$name not running (stalled pidfile)" + echo "$name not running (stale pidfile)" return 1 fi else @@ -209,13 +216,13 @@ start() --notif-il-sock=$GLITE_LB_NOTIF_SOCK \ --notif-il-fprefix=$GLITE_LB_NOTIF_FPREFIX \ $super $creds -i $BK_PIDFILE $port $wport $dumpdir $purgedir $lbreg_maildir $proxy $policy\ - $GLITE_LB_SERVER_OTHER_OPTIONS" + $GLITE_LB_SERVER_OTHER_OPTIONS" "/tmp/lb_proxy_serve.sock /tmp/lb_proxy_store.sock" if test -x $GLITE_LOCATION/bin/glite-lb-notif-interlogd; then start_daemon glite-lb-notif-interlogd "$NOTIF_IL_PIDFILE" "$GLITE_LOCATION/bin/glite-lb-notif-interlogd \ -f $GLITE_LB_NOTIF_FPREFIX -s $GLITE_LB_NOTIF_SOCK \ -i $NOTIF_IL_PIDFILE -M 10485760 \ - $creds $GLITE_LB_NOTIF_IL_OTHER_OPTIONS" + $creds $GLITE_LB_NOTIF_IL_OTHER_OPTIONS" "$GLITE_LB_NOTIF_SOCK" else echo Warning: glite-lb-notif-interlogd not installed, LB notifications will not work fi @@ -233,7 +240,7 @@ start() start_daemon "glite-lb-interlog for proxy" "$PROXY_IL_PIDFILE" "$GLITE_LOCATION/bin/glite-lb-interlogd \ -f $GLITE_LB_PROXY_FPREFIX -s $GLITE_LB_PROXY_SOCK \ -i $PROXY_IL_PIDFILE \ - $creds $GLITE_LB_PROXY_IL_OTHER_OPTIONS" + $creds $GLITE_LB_PROXY_IL_OTHER_OPTIONS" "$GLITE_LB_PROXY_SOCK" else echo Warning: glite-lb-interlogd not installed, logging to LB proxy will not work fi -- 1.8.2.3