59 lines
1.6 KiB
JavaScript
59 lines
1.6 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', async () => {
|
|
console.log('SSH连接成功');
|
|
|
|
try {
|
|
console.log('\n=== 检查服务器上的JS文件内容 ===');
|
|
await executeCommand('head -5 /www/huishou/dist/build/h5/assets/index-CFIPh5xV.js');
|
|
|
|
console.log('\n=== 检查服务器上的JS文件大小 ===');
|
|
await executeCommand('ls -la /www/huishou/dist/build/h5/assets/index-CFIPh5xV.js');
|
|
|
|
console.log('\n=== 检查服务器上的H5目录大小 ===');
|
|
await executeCommand('du -sh /www/huishou/dist/build/h5/');
|
|
|
|
console.log('\n=== 检查容器内H5目录大小 ===');
|
|
await executeCommand('docker exec huishou du -sh /usr/share/nginx/html/h5/');
|
|
|
|
console.log('\n=== 检查容器内JS文件内容 ===');
|
|
await executeCommand('docker exec huishou head -5 /usr/share/nginx/html/h5/assets/index-CFIPh5xV.js');
|
|
|
|
} catch (error) {
|
|
console.error('检查失败:', error.message);
|
|
} finally {
|
|
conn.end();
|
|
}
|
|
});
|
|
|
|
function executeCommand(cmd) {
|
|
return new Promise((resolve) => {
|
|
conn.exec(cmd, (err, stream) => {
|
|
if (err) {
|
|
console.error('命令执行错误:', err.message);
|
|
resolve();
|
|
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); |