guanghulab/image-studio/deploy/check-homepage.mjs
Guanghu Domestic Migration d1e47f4565
Some checks are pending
自动更新代码和重启 / update-and-restart (push) Waiting to run
CI检查 + 自动部署 / check (push) Waiting to run
CI检查 + 自动部署 / deploy (push) Blocked by required conditions
重启聊天服务 / restart (push) Waiting to run
chore: import sanitized domestic snapshot for REPO-002
Source snapshot: ca48d3ddf926d79aa138306164169baf764bb829
2026-07-17 15:54:41 +08:00

52 lines
1.7 KiB
JavaScript

/**
* 查看guanghulab.com首页
*/
const GZ = { ip: '43.139.217.141', port: 3910, key: 'zy_gtw_4a155446b7acc09fe46a2a29972c0ca5d9954da19c35dc23' }
async function callGK(srv, method, path, body = null) {
const url = `http://${srv.ip}:${srv.port}${path}`
const opts = { method, headers: { 'Authorization': `Bearer ${srv.key}`, 'Content-Type': 'application/json' } }
if (body) opts.body = JSON.stringify(body)
const res = await fetch(url, opts)
const text = await res.text()
try { return { status: res.status, data: JSON.parse(text) } }
catch { return { status: res.status, data: { raw: text } } }
}
async function exec(srv, cmd) {
const r = await callGK(srv, 'POST', '/exec', { cmd })
return r.data
}
async function readFile(srv, path) {
const r = await callGK(srv, 'POST', '/file/read', { path })
if (r.status === 200) return r.data.content
return null
}
async function main() {
// 查看首页目录
console.log('📂 首页目录结构:')
const r1 = await exec(GZ, 'ls -la /opt/guanghulab-repo/homepage/ 2>&1')
console.log(r1.stdout || r1.stderr)
// 读取index.html
console.log('\n📄 index.html:')
const html = await readFile(GZ, '/opt/guanghulab-repo/homepage/index.html')
if (html) console.log(html)
else console.log('(读取失败)')
// 看看子目录
console.log('\n📂 首页子目录:')
const r2 = await exec(GZ, 'find /opt/guanghulab-repo/homepage/ -type f 2>&1')
console.log(r2.stdout || r2.stderr)
// 看首页通过Nginx访问的效果
console.log('\n🔍 首页HTML:')
const r3 = await exec(GZ, `curl -s -k -H "Host: guanghulab.com" https://localhost/ 2>&1 | head -100`)
console.log(r3.stdout || r3.stderr)
}
main().catch(err => console.error('❌', err))