-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-irohas.sh
executable file
·44 lines (35 loc) · 1013 Bytes
/
run-irohas.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
#!/usr/bin/env bash
set -euo pipefail
shopt -s lastpipe
## Useful to use when iroha-swarm --without-docker
##TODO
# initdb /path/to/db -Upostgres
# postgres -D/path/to/db &
IROHAD=${IROHAD:-~/devel/iroha/build/bin/irohad}
COLORS=(0 39 126 184 214 141)
NOCOLOR="$(tput sgr0)"
colorful_prefix(){
# while read; do
# echo $'\e[38;5;'${COLORS[$i]}m"node$i | $NOCOLOR""$REPLY"
# done
PREFIX=$'\e[38;5;'${COLORS[$i]}m"node$i | $NOCOLOR"
sed s,^,"$PREFIX",
# awk '{print "'"$PREFIX "'" $0}'
}
PIDs=()
N=${1:-4}
for (( i=1; i<=N; ++i )) ;do
$IROHAD --config iroha$i.config --genesis_block genesis.block --keypair_name iroha$i \ #--overwrite_ledger --drop_state \
&>iroha$i.log & #1> >(colorful_prefix) 2> >(colorful_prefix) &
PIDs+=($!)
tail -f iroha$i.log | colorful_prefix &
sleep 0.1
done
wait
# kill ${PIDs[@]}
# sleep 10
# kill -9 ${PIDs[@]}
# while kill -0 ${PIDs[@]} ;do
# sleep 2;
# echo >&2 "----------- Waiting for PIDs ${PIDs[@]}"
# done