From 280c6e5cdf076def8e9070f33a560722d2856a8c Mon Sep 17 00:00:00 2001 From: wanglei <34475144@qq.com> Date: Thu, 25 Sep 2025 13:56:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=A1=B9=E7=9B=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=9F=BA=E4=BA=8EOpenresty=E6=A1=86=E6=9E=B6=E5=92=8C?= =?UTF-8?q?lua=E8=84=9A=E6=9C=AC=E8=BF=9B=E8=A1=8C=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AuthPlatform.iml | 11 +++++++ bat/openresty-restart.bat | 3 ++ bat/openresty-start.bat | 40 +++++++++++++++++++++++++ bat/openresty-status.bat | 7 +++++ bat/openresty-stop.bat | 6 ++++ conf/nginx.conf | 62 +++++++++++++++++++++++++++++++++++++++ logs/nginx.pid | 1 + 7 files changed, 130 insertions(+) create mode 100644 AuthPlatform.iml create mode 100644 bat/openresty-restart.bat create mode 100644 bat/openresty-start.bat create mode 100644 bat/openresty-status.bat create mode 100644 bat/openresty-stop.bat create mode 100644 conf/nginx.conf create mode 100644 logs/nginx.pid diff --git a/AuthPlatform.iml b/AuthPlatform.iml new file mode 100644 index 0000000..0495363 --- /dev/null +++ b/AuthPlatform.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/bat/openresty-restart.bat b/bat/openresty-restart.bat new file mode 100644 index 0000000..95368b3 --- /dev/null +++ b/bat/openresty-restart.bat @@ -0,0 +1,3 @@ +@echo off +call openresty-stop.bat +call openresty-start.bat diff --git a/bat/openresty-start.bat b/bat/openresty-start.bat new file mode 100644 index 0000000..b69a196 --- /dev/null +++ b/bat/openresty-start.bat @@ -0,0 +1,40 @@ +@echo off + +rem 启动标志 flag=0 表示之前已经启动 flag=1 表示现在立即启动 +set flag=0 + +rem 设置 openresty/nginx的安装目录 +set installPath=D:\work\OpenResty\openresty-1.27.1.2-win64 + +rem 设置 Nginx 项目的工作目录 +set projectPath=D:\OpenrestyPro\AuthService + +rem 设置 项目的配置文件 +set PROJECT_CONF=nginx.conf + +echo installPath: %installPath% +echo project prefix path: %projectPath% +echo config file: %projectPath%/conf/%PROJECT_CONF% +echo openresty starting..... + +rem 查找openresty/nginx进程信息,然后设置flag标志位 +tasklist|find /i "nginx.exe" > nul +if %errorlevel%==0 ( + echo "openresty/nginx already running ! " + rem exit /b +) else set flag=1 + +rem 如果需要,则启动 openresty/nginx +rem -p指定前缀路径,-c指定nginx配置文件 + +if %flag%==1 ( + start nginx.exe -p "%projectPath%" -c "%projectPath%/conf/%PROJECT_CONF%" + ping localhost -n 2 > nul +) + +rem 输出openresty/nginx的进程信息 +tasklist /fi "imagename eq nginx.exe" +tasklist|find /i "nginx.exe" > nul +if %errorlevel%==0 ( + echo "openresty/nginx starting succeced!" +) diff --git a/bat/openresty-status.bat b/bat/openresty-status.bat new file mode 100644 index 0000000..297996b --- /dev/null +++ b/bat/openresty-status.bat @@ -0,0 +1,7 @@ +@echo off +tasklist|find /i "nginx.exe" > nul +if %errorlevel%==0 ( +tasklist /fi "imagename eq nginx.exe" + echo "openresty/nginx is running!" + exit /b +) else echo "openresty/nginx is stoped!" diff --git a/bat/openresty-stop.bat b/bat/openresty-stop.bat new file mode 100644 index 0000000..94b368e --- /dev/null +++ b/bat/openresty-stop.bat @@ -0,0 +1,6 @@ +@echo off +tasklist|find /i "nginx.exe" > nul +if %errorlevel%==0 ( + taskkill /f /t /im nginx.exe > nul + echo "openresty/nginx stoped!" +)else echo "openresty/nginx not running!" diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..819e130 --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,62 @@ +worker_processes 2; +error_log logs/error.log info; +events { + worker_connections 1024; +} + +http { + default_type application/octet-stream; + access_log logs/access.log; + lua_package_path 'src/share/?.lua;;'; #lua 模块 + lua_package_cpath "src/share/lib/?.so;;"; #c模块 + ##include lua.conf; #导入自定义lua配置文件 + ##resolver 8.8.8.8; + lua_shared_dict share_mem_cache 10m; ##共享内存大小 + lua_shared_dict routes_cache 10m; ##路由内存大小 + + server { + listen 9090; + server_name localhost; + default_type text/html; + location = /favicon.ico { + log_not_found off; + access_log off; + } + + location /api { + content_by_lua_file src/api/api.lua; + } + + #location ^~ /api/ { + # rewrite_by_lua_block { + # local uri = ngx.var.uri + # if string.match(uri, "^/api/v1/") then + # ngx.req.set_uri("/api_v1") + # elseif string.match(uri, "^/api/v2/") then + # ngx.req.set_uri("/api_v2") + # end + # } + #} + + #location /api_v1 { + # content_by_lua_file conf/lua/api_v1.lua; + #} + + #location /api_v2 { + # content_by_lua_file conf/lua/api_v2.lua; + #} + + # 动态路由处理 + #location /router { + # access_by_lua_file "src/routes/dynamic_router.lua"; + # proxy_pass $target; + # proxy_set_header Host $host; + # proxy_set_header X-Real-IP $remote_addr; + #} + + # 路由更新接口 + #location /update-routes { + # content_by_lua_file "src/routes/route_updater.lua"; + #} + } +} diff --git a/logs/nginx.pid b/logs/nginx.pid new file mode 100644 index 0000000..70f822b --- /dev/null +++ b/logs/nginx.pid @@ -0,0 +1 @@ +12764