61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
const { Client } = require('ssh2');
|
|
const fs = require('fs');
|
|
|
|
const privateKey = fs.readFileSync('D:\\Trae\\huishou用户密钥id_ed25519', 'utf8');
|
|
|
|
const config = {
|
|
host: 'hs.yifenbao.cn',
|
|
port: 22,
|
|
username: 'root',
|
|
password: 'Torch1112'
|
|
};
|
|
|
|
const conn = new Client();
|
|
|
|
conn.on('ready', async () => {
|
|
console.log('SSH连接成功');
|
|
|
|
try {
|
|
console.log('\n=== 检查H5文件结构 ===');
|
|
await executeCommand('ls -la /www/huishou/dist/build/h5/');
|
|
|
|
console.log('\n=== 检查index.html内容 ===');
|
|
await executeCommand('head -50 /www/huishou/dist/build/h5/index.html');
|
|
|
|
console.log('\n=== 检查Nginx配置 ===');
|
|
await executeCommand('cat /www/huishou/admin/nginx.conf');
|
|
|
|
console.log('\n=== 检查容器内H5文件 ===');
|
|
await executeCommand('docker exec huishou ls -la /usr/share/nginx/html/h5/');
|
|
|
|
console.log('\n=== 测试H5访问 ===');
|
|
await executeCommand('curl -s http://localhost:4001/h5/ | head -30');
|
|
|
|
} catch (error) {
|
|
console.error('检查失败:', error.message);
|
|
} finally {
|
|
conn.end();
|
|
}
|
|
});
|
|
|
|
function executeCommand(cmd) {
|
|
return new Promise((resolve, reject) => {
|
|
conn.exec(cmd, (err, stream) => {
|
|
if (err) {
|
|
reject(err);
|
|
return;
|
|
}
|
|
|
|
stream.stdout.on('data', (data) => process.stdout.write(data));
|
|
stream.stderr.on('data', (data) => process.stdout.write(data));
|
|
|
|
stream.on('close', () => resolve());
|
|
});
|
|
});
|
|
}
|
|
|
|
conn.on('error', (err) => {
|
|
console.error('SSH连接错误:', err.message);
|
|
});
|
|
|
|
conn.connect(config); |