增加openresty

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

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

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

@ -1,6 +1,7 @@
#!/bin/sh
# 查找端口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
netstat -anp|grep $1|awk '{printf $7}'|cut -d/ -f1
echo $port
fi

Loading…
Cancel
Save