start.sh
1.06 KB
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
#!/bin/sh
#working directory
pwd="/Data/code/yoho-phplog"
pgrep="/usr/bin/pgrep"
wc="/usr/bin/wc"
lsof="/usr/sbin/lsof"
python="/usr/bin/python"
php="/Data/local/php/bin/php"
log_file=$pwd'/access.log'
if [ ! -f $log_file ];then
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
monitor "$php -f $pwd/HttpServer.php"
monitor "$php -f $pwd/HttpMqServer.php"
#tcp
monitor "$php -f $pwd/TcpServer.php"
#udp
monitor "$php -f $pwd/UdpServer.php"
#mqclient
monitor "$python $pwd/MqClient.py"
sleep 5
done