-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·32 lines (26 loc) · 1.01 KB
/
start.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
#!/bin/bash
cd $(dirname $0)
N=${1:-3}
for i in $(seq 1 $N); do
REDIS=$(( 6000 + i ))
PROXY=$(( 7000 + i ))
CONTROL=$(( 3000 + i ))
mkdir -p data/redis-$REDIS
if [[ ! -f data/redis-$REDIS/redis-$REDIS.pid ]]; then
if [[ -z $REDIS_AUTH ]]; then
redis-server <(sed 's/{{PORT}}/'$REDIS'/g' redis.conf.in | grep -v '{{PASS}}')
else
redis-server <(sed 's/{{PORT}}/'$REDIS'/g;s/{{PASS}}/'$REDIS_AUTH'/g' redis.conf.in)
fi
fi
mkdir -p data/hive-$CONTROL
if [[ ! -f data/hive-$CONTROL/hive.pid ]] ||
[[ $(cat /proc/$(cat data/hive-$CONTROL/hive.pid)/comm 2>/dev/null) != redis-hive ]]; then
if [[ -z $REDIS_AUTH ]]; then
./bin/redis-hive -r$REDIS -p$PROXY -c$CONTROL -mlocalhost $(seq 3001 $(( 3000 + N)) | sed 's/^/-o/') >> data/hive-$CONTROL/hive.log 2>&1 &
else
./bin/redis-hive -r$REDIS -p$PROXY -aREDIS_AUTH -c$CONTROL -mlocalhost $(seq 3001 $(( 3000 + N)) | sed 's/^/-o/') >> data/hive-$CONTROL/hive.log 2>&1 &
fi
echo $! > data/hive-$CONTROL/hive.pid
fi
done