forked from CodeChain-io/codechain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·70 lines (57 loc) · 1.57 KB
/
test.sh
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
if [ $# -eq 0 ]; then
echo "USAGE :"
echo " test NUM_CLIENTS [OPTIONS]"
exit 1
fi
NUM_CLIENTS=$1
OTHER_OPTIONS=${@:2}
BASE_DIR=$(cd "$(dirname "$0")"/.. && pwd)
LOG_DIR="/var/tmp/codechain"
DB_DIR=${BASE_DIR}/db
CODECHAIN_PORT_START=3484
RPC_PORT_START=8080
mkdir -p ${LOG_DIR}
mkdir -p ${DB_DIR}
run_server() {
if [ $1 -eq 0 ]; then
BOOTSTRAP=""
else
BOOTSTRAP="--bootstrap-addresses 127.0.0.1:${CODECHAIN_PORT_START}"
fi
cd ${BASE_DIR}
cargo run -- \
--db-path ${DB_DIR}/db$1 \
--port $((${CODECHAIN_PORT_START} + $1)) \
--jsonrpc-port $((${RPC_PORT_START} + $1)) \
--secret-key "`printf "%064x" $(($1 + 1))`" \
${BOOTSTRAP} \
${OTHER_OPTIONS} \
>> ${LOG_DIR}/codechain.log.$1 2>&1 &
}
echo "Building..."
cd ${BASE_DIR}
cargo build
run_server 0
echo "Waiting for startup...."
if [ -x /usr/bin/expect ]; then
/usr/bin/expect <<EOD
spawn tail -f ${LOG_DIR}/codechain.log.0
expect "TCP connection starts for"
EOD
else
tail -f ${LOG_DIR}/codechain.log.0 | grep -qm 1 "Initialization complete"
fi
for i in `seq 1 $((${NUM_CLIENTS} - 1))`; do
run_server $i
done
echo ""
echo "Running ${NUM_CLIENTS} clients"
echo "DB location : ${DB_DIR}/db*"
echo "Log : ${LOG_DIR}/codechain.log.*"
echo "Codechain port on ${CODECHAIN_PORT_START}..$((${CODECHAIN_PORT_START} + ${NUM_CLIENTS} - 1))"
echo "RPC port on ${RPC_PORT_START}..$((${RPC_PORT_START} + ${NUM_CLIENTS} - 1))"
echo ""
trap 'kill -9 `pidof codechain`' INT
cat ${LOG_DIR}/codechain.log.0
tail -f ${LOG_DIR}/codechain.log.0