summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/tests/start_cluster_hosts
blob: 37dda882caeb14537c819aa2c871b1e808b30227 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
#
# Start a cluster of brokers on local host, put the list of host port addresses
# in cluster.ports
#
# Arguments: [-k] [-p port] HOST [HOST...]
#  -p port to start broker on, can be 0. Actual ports recorded in cluster.addr.
#  -k kill any qpidd processes owned by this user before starting.
#
# Start a broker on each named host. Name a host twice to start multiple brokers.
#
# You must be able to ssh to each host and be in group ais.
# $QPIDD must be executable on each host.
# Logs go to syslog on each host, with a unique prefix per broker.
# 

QPIDD=${QPIDD:-$PWD/../qpidd}
LIBQPIDCLUSTER=${LIBQPIDCLUSTER:-$PWD/../.libs/libqpidcluster.so}
CLUSTER=$USER			# User name is default cluster name.
RESTART=NO

while getopts "kp:c:q:r" ARG ; do
    case $ARG in
	k) KILL=yes ;; 
	p) PORT="$OPTARG" ;;
	c) CLUSTER=$OPTARG ;;
	q) QPIDD=$OPTARG ;;
	l) LIBQPIDCLUSTER=$OPTARG ;;
	r) RESTART=yes ;;
	*) echo "Error parsing options: $ARG"; exit 1 ;;
    esac
done
shift `expr $OPTIND - 1`
test -n "$PORT" && PORTOPT="-p $PORT"
test "$KILL" = yes && KILL="$QPIDD -q $PORTOPT ;"
test -z "$*" && { echo Must specify at least one host; exit 1; }


OPTS="-d $PORTOPT --load-module $LIBQPIDCLUSTER --cluster-name=$CLUSTER --no-data-dir --auth=no --log-output=syslog"

num=0
for h in $*; do
    num=`expr $num + 1`	      # Give a unique log prefix to each node.
    cmd="$KILL $QPIDD $OPTS --log-prefix $num.$h"
    echo == $h
    out=`echo "$cmd" | ssh $h newgrp ais` || { echo $out ; exit 1; }
    if [ "$PORT" = 0 ] ; then p=$out; else p=$PORT; fi
    echo "$h $p" 
done