6dc051f26d
Load production env without .env override; sync-api-env targets .env.production; PM2 NODE_ENV=production; Prisma uses with-api-env.cjs on deploy. Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.1 KiB
Bash
40 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
# 续部署:user.runxian.top 统一路径入口 + nginx 切换
|
|
set -euo pipefail
|
|
|
|
APP_ROOT="${APP_ROOT:-/opt/dukang-haoke}"
|
|
H5_BASE="https://user.runxian.top"
|
|
|
|
cd "$APP_ROOT"
|
|
|
|
echo "==> 1. PM2 重启(H5 dist 已含 /user|shop|partner/ 路径)"
|
|
pm2 restart dukang-api dukang-h5-user dukang-h5-shop dukang-h5-partner dukang-admin-web
|
|
pm2 save
|
|
|
|
echo "==> 2. 安装 nginx HTTPS 配置"
|
|
install -m 644 "$APP_ROOT/deploy/nginx-runxian-dukang-ssl.conf" /etc/nginx/conf.d/dukang-runxian.conf
|
|
nginx -t
|
|
systemctl reload nginx
|
|
|
|
echo "==> 3. 更新 USER_H5_URL"
|
|
ENV_FILE="$APP_ROOT/server/dukang-api/.env.production"
|
|
if grep -q '^USER_H5_URL=' "$ENV_FILE"; then
|
|
sed -i "s|^USER_H5_URL=.*|USER_H5_URL=${H5_BASE}/user|" "$ENV_FILE"
|
|
else
|
|
echo "USER_H5_URL=${H5_BASE}/user" >> "$ENV_FILE"
|
|
fi
|
|
pm2 restart dukang-api
|
|
|
|
echo "==> 4. 验证"
|
|
for url in \
|
|
"${H5_BASE}/user/" \
|
|
"${H5_BASE}/shop/" \
|
|
"${H5_BASE}/partner/" \
|
|
"https://shop.runxian.top/" \
|
|
"https://dkapi.runxian.top/api/v1/health"; do
|
|
code="$(curl -sk -o /dev/null -w '%{http_code}' "$url" || echo fail)"
|
|
echo " $url -> $code"
|
|
done
|
|
|
|
echo "==> user.runxian.top 统一部署完成"
|