增加openresty

master
pan 4 years ago
parent 58e2f471be
commit 337a6ace91
  1. 15
      conf/nginx.conf
  2. 4
      shell/checkPort
  3. 5
      shell/findPortPid

@ -6,15 +6,20 @@ events {
http { http {
server { server {
listen 8080; listen 8080;
set $target '';
location / { location / {
access_by_lua ' access_by_lua '
local t = io.popen("/app/checkPort")
local a = t:read("*all")
local t = io.popen("checkPort") if( string.gsub(a,"%D","") == "0" )
local a = t:read("*all") then
ngx.var.target="http://127.0.0.1:5000"
ngx.say("<h1>当前进程"..a.."</h1>") else
ngx.var.target="http://127.0.0.1:2233"
end
'; ';
proxy_pass $target;
} }
} }
} }

@ -1,8 +1,8 @@
#!/bin/sh #!/bin/sh
# 检查客户端和服务端端口是否存在 # 检查客户端和服务端端口是否存在
#存在返回0否则返回1 #存在返回0否则返回1
source riskenv source /app/riskenv
if [[ `findPortPid $PORT|wc -l` -eq 1 && `findPortPid $serverPort|wc -l` -eq 1 ]] if [[ `/app/findPortPid $PORT|wc -l` -eq 1 && `/app/findPortPid $serverPort|wc -l` -eq 1 ]]
then then
echo 0 echo 0
else else

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
# 查找端口pid # 查找端口pid
if [[ $# == 1 && `netstat -antp|grep $1|wc -l` -eq 1 ]] port=`netstat -antpl|grep $1|awk '{printf $7}'|cut -d/ -f1`
if [[ $# == 1 && `echo $port|wc -l` -eq 1 ]]
then then
netstat -anp|grep $1|awk '{printf $7}'|cut -d/ -f1 echo $port
fi fi

Loading…
Cancel
Save