From f4beb90769b380b237654c8d07447b56e3dc84de Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Wed, 3 Jun 2026 09:33:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20nginx=20reload=20=E6=94=B9=E7=94=A8?= =?UTF-8?q?=20systemctl=20reload-or-restart=EF=BC=8C=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E7=A9=BA=20PID=20=E6=96=87=E4=BB=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit nginx -s reload 依赖 /run/nginx.pid,该文件为空时报 invalid PID number。 改用 systemctl reload-or-restart(经 systemd MAINPID 发 HUP,运行中则 reload、 未运行则启动),并 enable nginx 保证重启后自启。 Co-Authored-By: Claude Opus 4.8 --- CHANGELOG.md | 5 +++++ scripts/ci/deploy.sh | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97e589c..63b90b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.8] - 2026-06-03 + +### 修复 +- 修复 EC2 部署最后一步 nginx reload 失败(`invalid PID number`):改用 `systemctl reload-or-restart nginx`(经 systemd MAINPID 发 HUP,不依赖空的 /run/nginx.pid),并 `enable nginx` 确保重启后自启 + ## [1.0.7] - 2026-06-03 ### 修复 diff --git a/scripts/ci/deploy.sh b/scripts/ci/deploy.sh index 5f8b928..fb6037c 100755 --- a/scripts/ci/deploy.sh +++ b/scripts/ci/deploy.sh @@ -126,9 +126,13 @@ mkdir -p /opt/jiu/marketing rsync -a --delete /tmp/jiu-marketing-new/ /opt/jiu/marketing/ rm -rf /tmp/jiu-marketing-new -# Update nginx config and reload +# Update nginx config and reload. +# reload-or-restart: reload if nginx is running, start it if it's not — avoids +# `nginx -s reload` failing with "invalid PID number" when nginx isn't running +# (e.g. after an EC2 reboot where nginx didn't auto-start). sudo cp /tmp/nginx-jiu.conf /etc/nginx/conf.d/jiu.conf -sudo nginx -t && sudo nginx -s reload +sudo systemctl enable nginx >/dev/null 2>&1 || true # auto-start on future reboots +sudo nginx -t && sudo systemctl reload-or-restart nginx echo "Deploy complete!" ENDSSH