60 lines
1.8 KiB
Plaintext
Executable File
60 lines
1.8 KiB
Plaintext
Executable File
#!/usr/bin/expect -f
|
|
# 部署 Phase 7 - upload 重做 + centers + home-intro + admin 重构
|
|
# 用法: expect deploy-v4-cleanup.exp
|
|
|
|
set timeout 60
|
|
set password "Szgt888."
|
|
set host "124.221.67.199"
|
|
set user "root"
|
|
set remote_dir "/opt/yuyueguahao"
|
|
|
|
puts "\n>>> STEP 1: 上传后端 (新模块 + 改动)"
|
|
foreach f {
|
|
server/src/modules/upload
|
|
server/src/modules/center
|
|
server/src/modules/homeIntro
|
|
server/src/seeds/centers.js
|
|
server/src/modules/index.js
|
|
server/src/index.js
|
|
server/src/schema.sql
|
|
} {
|
|
spawn scp -r $f ${user}@${host}:${remote_dir}/$f
|
|
expect {
|
|
"password:" { send "$password\r" }
|
|
"yes/no" { send "yes\r"; exp_continue }
|
|
}
|
|
expect eof
|
|
}
|
|
|
|
puts "\n>>> STEP 2: 上传 admin"
|
|
foreach f {
|
|
admin/app.js
|
|
admin/index.html
|
|
admin/styles.css
|
|
} {
|
|
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 3: 重启 PM2 + 验证新表自动创建"
|
|
spawn ssh ${user}@${host} "cd ${remote_dir}/server && pm2 restart yuyueguahao-api 2>&1; sleep 3; pm2 logs yuyueguahao-api --lines 20 --nostream 2>&1 | head -40"
|
|
expect {
|
|
"password:" { send "$password\r" }
|
|
"yes/no" { send "yes\r"; exp_continue }
|
|
}
|
|
expect eof
|
|
|
|
puts "\n>>> STEP 4: 验证 endpoints"
|
|
spawn ssh ${user}@${host} "echo '---/api/v1/centers---' && curl -s 'http://localhost:3000/api/v1/centers' && echo '' && echo '---/api/v1/home-intro---' && curl -s 'http://localhost:3000/api/v1/home-intro' && echo '' && echo '---/api/v1/banners---' && curl -s 'http://localhost:3000/api/v1/banners' | head -c 300"
|
|
expect {
|
|
"password:" { send "$password\r" }
|
|
"yes/no" { send "yes\r"; exp_continue }
|
|
}
|
|
expect eof
|
|
|
|
puts "\n>>> DEPLOY DONE"
|