增加openresty

master
pan 4 years ago
parent da279228a4
commit 24933dc321
  1. 6
      shell/killNode
  2. 12
      shell/savePid
  3. 22
      shell/updateRisk

@ -1,13 +1,13 @@
#!/bin/sh
#杀死进程
if [ -e *.log ]
if [ -e pid ]
then
pid=`stat *.log|awk 'NR>1{next}{c=$0;gsub(/\D/,"",c);print c}'`
pid=`echo pid`
kill -9 $pid
if [ $? -eq 0 ]
then
echo "kill $pid success"
rm -f *.log
rm -f pid
fi
fi
./run.sh

@ -1,16 +1,18 @@
#!/bin/sh
#保存应用进程pid
echo "findPort $1"
#重试时间
second=5s
while true
do
pid=`findPortPid $1`
if [ -z $pid ]
if [ `$pid|wc -l` -eq 0 ]
then
echo "pid not found!!!"
sleep 1s
echo "没有找到端口$1的pid,$second后重试"
sleep $second
else
echo "pid is $pid"
touch $pid.log && chmod +x $pid.log
echo "端口$1的pid:$pid"
echo $pid>pid
break
fi
done

@ -1,6 +1,8 @@
#!/bin/sh
#自动部署脚本
echo $$>$1.pid
cd /app
source riskenv
@ -22,14 +24,22 @@ function run(){
fi
}
#检查是否正在部署
result=`ps -ef|grep 'updateRisk $1'|wc -l`
echo $result
if [ ! -z $result ]
#如果当前存在自动部署进程直接kill掉
if [ `ls -l *.pid|wc -l` -gt 0 ]
then
for file in *.pid
do
pid=`cat $file`
kill -9 $pid
if [ $? -eq 0 ]
then
echo "检测到自动部署$1进程在运行,直接kill掉"
kill -9 $result
echo "成功杀死进程:$pid"
rm -f $file
fi
done
fi
run $1
rm -f $1.pid

Loading…
Cancel
Save