start.sh
1017 Bytes
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
#!/bin/sh
#配置读取
vars=`sed -n '/^pwd\|^python\|^php\|^log_file/s/ \{1,\}= \{1,\}/=/p' Config.lua`
eval $vars
if [ ! -f "$log_file" ];then
dir=`dirname $log_file`
if [ ! -d $dir ];then
mkdir -p $dir
fi
touch $log_file
chmod 777 $log_file
fi
monitor(){
#pid=`ps aux|grep $1.php|$wc -l`
pid=`ps aux|grep "$1"|wc -l`
if [ $pid -le 1 ];then
msg="At time: `date` :$1 is stop ."
echo $msg
echo $msg >> $log_file
#cmd="$php -f $pwd/$1.php"
cmd="$1"
echo $cmd
echo $cmd >> $log_file
$cmd 2>&1 &
else
echo "$1 is running ."
fi
}
while true;do
#http mq
#monitor "$php -f $pwd/HttpMqServer.php"
#mqclient
#monitor "$python $pwd/MqClient.py"
monitor "$python $pwd/GoMqClient.py"
#xhprof.io
monitor "$php -f $pwd/MqXhprof.php"
sleep 5
done