diff --git a/Jenkinsfile b/Jenkinsfile index 7049c18..f51fe67 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -29,9 +29,16 @@ pipeline { cp -r ${DIST_PATH}/* ${DEPLOY_DIR}/ echo "主节点部署完成:${DIST_PATH} → ${DEPLOY_DIR}" - echo "重启 Nginx 服务..." - systemctl restart nginx - echo "已重启服务" + # 2. Nginx 操作(优先热重载,无停机) + echo "检查 Nginx 配置语法..." + /usr/sbin/nginx -t # 先校验配置,避免重载失败 + + echo "热重载 Nginx 配置..." + # Debian systemd 下的正确写法(绝对路径+sudo,需提前配置免密) + sudo /usr/bin/systemctl reload nginx # 重载比 restart 更友好 + # 若必须重启:sudo /usr/bin/systemctl restart nginx + + echo "Nginx 操作完成" """ } }