diff --git a/shell/checkPort b/shell/checkPort new file mode 100644 index 0000000..3c4955e --- /dev/null +++ b/shell/checkPort @@ -0,0 +1,10 @@ +#!/bin/sh +# 检查端口是否存在 + +source riskenv +if [[ `findPortPid $PORT|wc -l` -eq 1 && `findPortPid $serverPort|wc -l` -eq 1 ]] +then + echo 0 +else + echo 1 +fi \ No newline at end of file diff --git a/shell/findPortPid b/shell/findPortPid index 09e34da..a457137 100644 --- a/shell/findPortPid +++ b/shell/findPortPid @@ -1,8 +1,6 @@ #!/bin/sh # 查找端口pid -if [ $# == 1 ] +if [[ $# == 1 && `netstat -antp|grep $1|wc -l` -eq 1 ]] then - netstat -antp|grep $1|awk '{c=$7;split(c,d,"/");print match(d[1],/\d+/)?d[1]:-1}' -else - echo port param not found! + netstat -anp|grep $1|awk '{printf $7}'|cut -d/ -f1 fi diff --git a/shell/riskenv b/shell/riskenv new file mode 100644 index 0000000..28b7799 --- /dev/null +++ b/shell/riskenv @@ -0,0 +1,14 @@ +#!/bin/sh +# 设置环境变量 + +#服务端端口 +export PORT=2233 +#客户端访问地址 +export webClient=https://risk.kirito.cool +#客户端端口 +export serverPort=5000 +#客户端监听地址 +export listenAddress=0.0.0.0 +#服务端访问地址 +export apiServer=https://risk.kirito.cool + diff --git a/shell/updateRisk b/shell/updateRisk index d6c1222..7d317f0 100644 --- a/shell/updateRisk +++ b/shell/updateRisk @@ -3,17 +3,7 @@ cd /app -#服务端端口 -export PORT=2233 -#客户端访问地址 -export webClient=https://risk.kirito.cool -#客户端端口 -export serverPort=5000 -#客户端监听地址 -export listenAddress=0.0.0.0 -#服务端访问地址 -export apiServer=https://risk.kirito.cool - +source riskenv function run(){ if [ ! -e $1 ] @@ -33,7 +23,7 @@ function run(){ } #检查是否正在部署 -result=`ps -ef|grep 'updateRisk $1'|awk 'NR>1{next}{print $1}'` +result=`ps -ef|grep 'updateRisk $1'|wc -l` echo $result if [ ! -z $result ] then