summaryrefslogtreecommitdiff
path: root/redis-node/redis_protect.sh
blob: a2f7967753f6424bc25c6ca654d33363d875c025 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
if [ $# -lt 1 ];then
        echo -e "usage:\n\tprotect.sh redis_instance_num\nexample:\n\tprotect.sh 6"
        exit 1
fi
((n = $1+1))
while true; do
	redis_num=`ps -ef|grep redis-server|wc -l`
	#echo $redis_num
	if [ $redis_num -lt $n ];then
		for dir in $(ls /home/mesasoft/redis/redis-node/)
		do
			[ -d $dir ] && `redis-server /home/mesasoft/redis/redis-node/$dir/redis.conf` 
		done
		#echo program crashed, restart at `date +"%w %Y/%m/%d, %H:%M:%S"` >> RESTART.log
	fi
	sleep 5
done