48 lines
1.0 KiB
JavaScript
48 lines
1.0 KiB
JavaScript
import { Client } from 'ssh2';
|
|
|
|
const conn = new Client();
|
|
|
|
conn.on('ready', () => {
|
|
console.log('=== 检查后端日志 ===\n');
|
|
|
|
conn.exec('docker logs huishou-backend --tail 30', (err, stream) => {
|
|
if (err) {
|
|
console.log('读取日志失败:', err.message);
|
|
conn.end();
|
|
return;
|
|
}
|
|
|
|
stream.on('data', (data) => {
|
|
console.log(data.toString());
|
|
});
|
|
|
|
stream.on('close', () => {
|
|
conn.exec('curl -s http://127.0.0.1:4000/', (err, stream2) => {
|
|
if (err) {
|
|
console.log('\n本地测试失败:', err.message);
|
|
conn.end();
|
|
return;
|
|
}
|
|
|
|
stream2.on('data', (data) => {
|
|
console.log('\n本地响应:', data.toString());
|
|
});
|
|
|
|
stream2.on('close', () => {
|
|
conn.end();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
conn.on('error', (err) => {
|
|
console.log('连接错误:', err.message);
|
|
});
|
|
|
|
conn.connect({
|
|
host: 'hs.yifenbao.cn',
|
|
port: 22,
|
|
username: 'root',
|
|
password: 'Torch1112'
|
|
}); |