Files
huishou/check-build-log.mjs
2026-07-27 14:07:26 +08:00

44 lines
1.0 KiB
JavaScript

import { Client } from 'ssh2';
const conn = new Client();
conn.on('ready', () => {
console.log('=== 检查构建日志 ===\n');
conn.exec('cat /tmp/server.log 2>/dev/null || echo "日志不存在"', (err, stream) => {
if (err) {
console.log('读取日志失败:', err.message);
} else {
stream.on('data', (data) => {
console.log('日志:', data.toString());
}
}
stream.on('close', () => {
conn.exec('cd /www/huishou && npm run build:h5 2>&1 | tail -50', (err, stream2) => {
if (err) {
console.log('构建失败:', err.message);
} else {
stream2.on('data', (data2) => {
console.log('\n构建输出:', data2.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'
});