78 lines
2.1 KiB
JavaScript
78 lines
2.1 KiB
JavaScript
const { Client } = require('ssh2');
|
|
|
|
const config = {
|
|
host: 'hs.yifenbao.cn',
|
|
port: 22,
|
|
username: 'root',
|
|
password: 'Torch1112'
|
|
};
|
|
|
|
const conn = new Client();
|
|
|
|
conn.on('ready', () => {
|
|
console.log('SSH连接成功');
|
|
|
|
// 测试从外部访问的CSS文件
|
|
conn.exec('curl -s http://localhost:4001/h5/assets/list-CHpyn9E7.css | grep -o "debug-info"', (err, stream) => {
|
|
if (err) {
|
|
console.error('执行命令错误:', err.message);
|
|
conn.end();
|
|
return;
|
|
}
|
|
|
|
let output = '';
|
|
stream.stdout.on('data', (data) => {
|
|
output += data.toString();
|
|
});
|
|
|
|
stream.on('close', () => {
|
|
console.log('curl测试CSS文件中的debug-info:');
|
|
console.log(output || '未找到');
|
|
|
|
// 测试JS文件
|
|
conn.exec('curl -s http://localhost:4001/h5/assets/pages-order-list.Oq2uWnRW.js | grep -o "tabBar.*safeArea[^}]*"', (err, stream) => {
|
|
if (err) {
|
|
console.error('执行命令错误:', err.message);
|
|
conn.end();
|
|
return;
|
|
}
|
|
|
|
let jsOutput = '';
|
|
stream.stdout.on('data', (data) => {
|
|
jsOutput += data.toString();
|
|
});
|
|
|
|
stream.on('close', () => {
|
|
console.log('\ncurl测试JS文件中的调试信息:');
|
|
console.log(jsOutput || '未找到');
|
|
|
|
// 检查nginx配置
|
|
conn.exec('cat /www/huishou/admin/nginx.conf | grep -A 10 "location /h5"', (err, stream) => {
|
|
if (err) {
|
|
console.error('执行命令错误:', err.message);
|
|
conn.end();
|
|
return;
|
|
}
|
|
|
|
let nginxOutput = '';
|
|
stream.stdout.on('data', (data) => {
|
|
nginxOutput += data.toString();
|
|
});
|
|
|
|
stream.on('close', () => {
|
|
console.log('\nnginx h5配置:');
|
|
console.log(nginxOutput);
|
|
conn.end();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
conn.on('error', (err) => {
|
|
console.error('SSH连接错误:', err.message);
|
|
});
|
|
|
|
conn.connect(config); |