From aa2b7d51cebc3977e51b567fe5ad6ca71a2d5d99 Mon Sep 17 00:00:00 2001 From: wangzhibiao Date: Mon, 14 Sep 2026 13:02:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=81=E7=BB=AD=E9=9B=86=E6=88=90=EF=BC=9A?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E8=84=9A=E6=9C=AC=E9=9B=86=E6=88=90=E5=85=8D?= =?UTF-8?q?root=E7=94=A8=E6=88=B7=E7=BA=A7Nginx=E8=87=AA=E5=8A=A8=E5=90=AF?= =?UTF-8?q?=E5=81=9C=E4=B8=8E=E5=8F=8D=E5=90=91=E4=BB=A3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/restart-all.sh | 63 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/deploy/restart-all.sh b/deploy/restart-all.sh index 848ddf0be..afc00282e 100644 --- a/deploy/restart-all.sh +++ b/deploy/restart-all.sh @@ -65,9 +65,68 @@ for i in {1..35}; do RES=$(curl -s "http://127.0.0.1:${SERVER_PORT}/captchaImage" 2>/dev/null) if echo "$RES" | grep -q '"code":200'; then echo "后端健康检查通过!验证码接口返回正常!服务已在端口 $SERVER_PORT 成功运行!" - exit 0 + break fi sleep 2 done -echo "后端启动中或未在预期时间内完成自检,请检查日志: tail -n 50 $LOG_PATH" +echo "=== 3. 检查并启动/重载前端 Web 服务 (Nginx 8082) ===" +NGINX_DIR="$DEPLOY_ROOT/nginx" +NGINX_CONF="$NGINX_DIR/nginx.conf" +mkdir -p "$NGINX_DIR/temp" + +if [ ! -f "$NGINX_CONF" ]; then + cat << 'NGINX_EOF' > "$NGINX_CONF" +pid /data2/wzb/deploy/nginx/nginx.pid; +error_log /data2/wzb/deploy/nginx/error.log; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + client_body_temp_path /data2/wzb/deploy/nginx/temp/client_body; + proxy_temp_path /data2/wzb/deploy/nginx/temp/proxy; + fastcgi_temp_path /data2/wzb/deploy/nginx/temp/fastcgi; + uwsgi_temp_path /data2/wzb/deploy/nginx/temp/uwsgi; + scgi_temp_path /data2/wzb/deploy/nginx/temp/scgi; + + access_log /data2/wzb/deploy/nginx/access.log; + + sendfile on; + keepalive_timeout 65; + + server { + listen 8082; + server_name localhost; + + location / { + root /data2/wzb/deploy/frontend; + try_files $uri $uri/ /index.html; + index index.html; + } + + location /prod-api/ { + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header REMOTE-HOST $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_pass http://127.0.0.1:8092/; + } + } +} +NGINX_EOF +fi + +if pgrep -u $(whoami) -f "nginx: master" >/dev/null; then + echo "平滑重载前端 Nginx 服务..." + /usr/sbin/nginx -c "$NGINX_CONF" -s reload +else + echo "启动前端 Nginx 服务..." + /usr/sbin/nginx -c "$NGINX_CONF" +fi + +echo "=== 部署全部就绪!前端访问地址: http://192.168.139.230:8082 ==="