38 lines
1.8 KiB
Plaintext
Executable File
38 lines
1.8 KiB
Plaintext
Executable File
#!/usr/bin/expect -f
|
|
# 部署:图片 URL 绝对化修复
|
|
# - 后端:新增 utils/url.js + 4 个 DTO 应用 toAbsoluteUrl + config/service.js 递归应用
|
|
# - 前端:services/request.ts 设置 BASE_URL 为公网地址
|
|
# - 重启 PM2 让后端生效;前端需要在小程序开发工具里点"编译"重新构建
|
|
set timeout 60
|
|
set password "Szgt888."
|
|
set host "124.221.67.199"
|
|
set user "root"
|
|
set remote_dir "/opt/yuyueguahao"
|
|
|
|
puts "\n>>> STEP 1: 上传后端 (新增 url.js + 修改 5 个文件)"
|
|
foreach f {
|
|
server/src/utils/url.js
|
|
server/src/modules/upload/route.js
|
|
server/src/modules/banner/dto.js
|
|
server/src/modules/center/dto.js
|
|
server/src/modules/homeIntro/dto.js
|
|
server/src/modules/hospitalImage/dto.js
|
|
server/src/modules/config/service.js
|
|
} {
|
|
spawn scp $f ${user}@${host}:${remote_dir}/$f
|
|
expect { "password:" { send "$password\r" } "yes/no" { send "yes\r"; exp_continue } }
|
|
expect eof
|
|
}
|
|
|
|
puts "\n>>> STEP 2: 重启 PM2"
|
|
spawn ssh ${user}@${host} "pm2 restart yuyueguahao-api 2>&1 && sleep 2"
|
|
expect { "password:" { send "$password\r" } "yes/no" { send "yes\r"; exp_continue } }
|
|
expect eof
|
|
|
|
puts "\n>>> STEP 3: 验证 API 返回的 URL 是绝对地址"
|
|
spawn ssh ${user}@${host} "echo '--- banners ---' && curl -s 'http://localhost:3000/api/v1/banners?enabled=true' | head -c 600 && echo '' && echo '--- centers ---' && curl -s 'http://localhost:3000/api/v1/centers?enabled=true' | head -c 600 && echo '' && echo '--- home-intro ---' && curl -s 'http://localhost:3000/api/v1/home-intro' | head -c 600 && echo '' && echo '--- config/home ---' && curl -s 'http://localhost:3000/api/v1/config/home' | head -c 600"
|
|
expect { "password:" { send "$password\r" } "yes/no" { send "yes\r"; exp_continue } }
|
|
expect eof
|
|
|
|
puts "\n>>> DONE - 后端已部署。请在小程序开发者工具中点'编译'重新构建前端"
|