clouddreamai-cicd-setup 1.5.29 → 1.5.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/scripts/deploy.sh +29 -0
package/package.json
CHANGED
|
@@ -25,6 +25,35 @@ fi
|
|
|
25
25
|
|
|
26
26
|
echo "开始部署 $APP_NAME 到 $ENV_TYPE 环境 (端口: $APP_PORT)..."
|
|
27
27
|
|
|
28
|
+
# 检查端口是否被占用(排除当前应用的容器)
|
|
29
|
+
check_port() {
|
|
30
|
+
local PORT=$1
|
|
31
|
+
# 获取占用端口的进程,排除当前应用的 docker-proxy
|
|
32
|
+
local OCCUPIED=$(lsof -i :$PORT -t 2>/dev/null | while read PID; do
|
|
33
|
+
PROC_NAME=$(ps -p $PID -o comm= 2>/dev/null)
|
|
34
|
+
PROC_CMD=$(ps -p $PID -o args= 2>/dev/null)
|
|
35
|
+
# 如果是 docker-proxy 且属于当前应用,跳过
|
|
36
|
+
if [[ "$PROC_NAME" == "docker-proxy" ]] && docker ps --format '{{.Names}}' | grep -q "^${APP_NAME}"; then
|
|
37
|
+
continue
|
|
38
|
+
fi
|
|
39
|
+
echo "$PID"
|
|
40
|
+
done)
|
|
41
|
+
|
|
42
|
+
if [ -n "$OCCUPIED" ]; then
|
|
43
|
+
echo "❌ 端口 $PORT 已被占用:"
|
|
44
|
+
lsof -i :$PORT 2>/dev/null | head -5
|
|
45
|
+
echo ""
|
|
46
|
+
echo "请检查端口配置或停止占用端口的进程"
|
|
47
|
+
exit 1
|
|
48
|
+
fi
|
|
49
|
+
echo "✓ 端口 $PORT 可用"
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
# 检查端口(仅在非更新部署时检查)
|
|
53
|
+
if ! docker ps --format '{{.Names}}' | grep -q "^${APP_NAME}"; then
|
|
54
|
+
check_port $APP_PORT
|
|
55
|
+
fi
|
|
56
|
+
|
|
28
57
|
# Nginx 反向代理配置函数
|
|
29
58
|
configure_nginx_proxy() {
|
|
30
59
|
local DOMAIN=$1
|