```
feat(deploy): 添加部署路径权限检查功能
Webhook 由 PHP(www) 触发,项目目录必须对当前用户可写。
添加了对 DEPLOY_PATH 的写权限检查,如果当前用户对部署路径没有写权限,
则显示错误信息并退出部署流程。同时提供修复建议:
chown -R www:www ${DEPLOY_PATH} && chmod -R u+rwX ${DEPLOY_PATH}
```
这个提交包含在:
48
deploy/supervisor/install.sh
普通文件
48
deploy/supervisor/install.sh
普通文件
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
# 将 Shopro 队列 Supervisor 配置安装到服务器
|
||||
# 用法(root):
|
||||
# DEPLOY_PATH=/www/wwwroot/chufang.gynhc.com PHP_BIN=/www/server/php/74/bin/php bash deploy/supervisor/install.sh
|
||||
set -euo pipefail
|
||||
|
||||
DEPLOY_PATH="${DEPLOY_PATH:-/www/wwwroot/chufang.gynhc.com}"
|
||||
PHP_BIN="${PHP_BIN:-$(command -v php || true)}"
|
||||
CONF_SRC="${DEPLOY_PATH}/deploy/supervisor/shopro-queue.conf"
|
||||
CONF_DST="${SUPERVISOR_CONF_DIR:-/etc/supervisor/conf.d}/shopro-queue.conf"
|
||||
|
||||
if [[ -z "$PHP_BIN" || ! -x "$PHP_BIN" ]]; then
|
||||
echo "ERROR: 找不到可执行的 PHP,请设置 PHP_BIN,例如:"
|
||||
echo " PHP_BIN=/www/server/php/74/bin/php"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$CONF_SRC" ]]; then
|
||||
echo "ERROR: 配置文件不存在: $CONF_SRC"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "${DEPLOY_PATH}/think" ]]; then
|
||||
echo "ERROR: 项目根目录不正确,未找到 think: ${DEPLOY_PATH}/think"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "${DEPLOY_PATH}/runtime/log"
|
||||
|
||||
sed \
|
||||
-e "s|PHP_BIN_PLACEHOLDER|${PHP_BIN}|g" \
|
||||
-e "s|DEPLOY_PATH_PLACEHOLDER|${DEPLOY_PATH}|g" \
|
||||
"$CONF_SRC" > "$CONF_DST"
|
||||
|
||||
echo "已写入: $CONF_DST"
|
||||
echo "PHP: $PHP_BIN"
|
||||
echo "项目: $DEPLOY_PATH"
|
||||
|
||||
if command -v supervisorctl >/dev/null 2>&1; then
|
||||
supervisorctl reread
|
||||
supervisorctl update
|
||||
supervisorctl status shopro-queue:*
|
||||
else
|
||||
echo "WARN: 未找到 supervisorctl,请手动执行:"
|
||||
echo " supervisorctl reread && supervisorctl update && supervisorctl status"
|
||||
fi
|
||||
|
||||
echo "完成。"
|
||||
@@ -0,0 +1,60 @@
|
||||
; Shopro 队列守护(Supervisor)
|
||||
;
|
||||
; 安装步骤见下方注释,或阅读 deploy/supervisor/install.sh
|
||||
;
|
||||
; 队列说明:
|
||||
; shopro-high 支付后处理(返积分、减库存、拼团、打印小票等,需优先消费)
|
||||
; shopro 订单自动关闭/确认/评价、消息通知、分销升级、活动等
|
||||
;
|
||||
; 使用前请修改:
|
||||
; 1. PHP_BIN → 服务器 php 绝对路径(宝塔常见:/www/server/php/74/bin/php)
|
||||
; 2. DEPLOY_PATH → 站点根目录(含 think 文件,非 public)
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; 高优先级队列(积分返还、打印等)
|
||||
; ---------------------------------------------------------------------------
|
||||
[program:shopro-queue-high]
|
||||
process_name=%(program_name)s_%(process_num)02d
|
||||
command=PHP_BIN_PLACEHOLDER DEPLOY_PATH_PLACEHOLDER/think queue:listen --queue shopro-high --sleep 1 --timeout 120 --memory 256
|
||||
directory=DEPLOY_PATH_PLACEHOLDER
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startsecs=3
|
||||
startretries=10
|
||||
stopasgroup=true
|
||||
killasgroup=true
|
||||
stopwaitsecs=120
|
||||
user=www
|
||||
numprocs=1
|
||||
redirect_stderr=true
|
||||
stdout_logfile=DEPLOY_PATH_PLACEHOLDER/runtime/log/supervisor-shopro-high.log
|
||||
stdout_logfile_maxbytes=20MB
|
||||
stdout_logfile_backups=10
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; 普通队列(自动关单、通知、分销等)
|
||||
; ---------------------------------------------------------------------------
|
||||
[program:shopro-queue]
|
||||
process_name=%(program_name)s_%(process_num)02d
|
||||
command=PHP_BIN_PLACEHOLDER DEPLOY_PATH_PLACEHOLDER/think queue:listen --queue shopro --sleep 3 --timeout 120 --memory 256
|
||||
directory=DEPLOY_PATH_PLACEHOLDER
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startsecs=3
|
||||
startretries=10
|
||||
stopasgroup=true
|
||||
killasgroup=true
|
||||
stopwaitsecs=120
|
||||
user=www
|
||||
numprocs=1
|
||||
redirect_stderr=true
|
||||
stdout_logfile=DEPLOY_PATH_PLACEHOLDER/runtime/log/supervisor-shopro.log
|
||||
stdout_logfile_maxbytes=20MB
|
||||
stdout_logfile_backups=10
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; 分组(可选,便于 supervisorctl 批量管理)
|
||||
; ---------------------------------------------------------------------------
|
||||
[group:shopro-queue]
|
||||
programs=shopro-queue-high,shopro-queue
|
||||
priority=999
|
||||
在新工单中引用
屏蔽一个用户