summaryrefslogtreecommitdiff
path: root/qpid/java/broker/bin/qpid.stopall
diff options
context:
space:
mode:
authorRobert Greig <rgreig@apache.org>2007-04-19 09:33:00 +0000
committerRobert Greig <rgreig@apache.org>2007-04-19 09:33:00 +0000
commite400dd2269719b4abdf3e5321861db62375204df (patch)
tree8320a7281d4a305ab56c50658d6daa26d87e8e21 /qpid/java/broker/bin/qpid.stopall
parent5d48c521f7b8410c9051e4af9e4f75ee23fcf638 (diff)
downloadqpid-python-e400dd2269719b4abdf3e5321861db62375204df.tar.gz
Merged revisions 520843 via svnmerge from
https://svn.apache.org/repos/asf/incubator/qpid/branches/M2 ........ r520843 | ritchiem | 2007-03-21 11:24:40 +0000 (Wed, 21 Mar 2007) | 1 line Added two scripts to stop the running broker without having to first record the running pid. ........ git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@530349 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker/bin/qpid.stopall')
-rw-r--r--qpid/java/broker/bin/qpid.stopall57
1 files changed, 57 insertions, 0 deletions
diff --git a/qpid/java/broker/bin/qpid.stopall b/qpid/java/broker/bin/qpid.stopall
new file mode 100644
index 0000000000..f6862842c9
--- /dev/null
+++ b/qpid/java/broker/bin/qpid.stopall
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+# qpid.stopall script
+#
+# Script attempts to stop all PROGRAMs running under the current user
+# Utilises qpid.stop to perform the actual stopping
+#
+
+MAX_ATTEMPTS=5
+SLEEP_DELAY=2
+PROGRAM="org.apache.qpid.server.Main"
+
+#
+# grep ps for instances of $PROGRAM and collect PIDs
+#
+lookup()
+{
+pids=`ps o pid,command |grep -v grep | grep $PROGRAM | cut -d ' ' -f 1`
+result=`echo -n $pids | wc -l`
+}
+
+
+#
+# Show the PS output for given set of pids
+#
+showPids()
+{
+ps p $pids
+}
+
+
+#
+# Main Run
+#
+
+lookup
+
+if [[ $result == 0 ]] ; then
+ echo "No Qpid Brokers found running under user '$USER'"
+ exit 0
+fi
+
+for pid in $pids ; do
+
+qpid.stop $pid
+
+done
+
+# Check we have quit all
+lookup
+
+if [[ $result == 0 ]] ; then
+ echo "All Qpid brokers successfully quit"
+else
+ echo "Some brokers were not quit"
+ showPids $pids
+fi