```
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 "完成。"
|
||||
在新工单中引用
屏蔽一个用户