Files
huishou/debug-server.mjs
T
2026-07-27 14:07:26 +08:00

76 lines
2.0 KiB
JavaScript

import { Client } from 'ssh2';
const conn = new Client();
conn.on('ready', () => {
console.log('=== 调试服务器 ===\n');
conn.exec('cd /www/huishou && ls -la', (err, stream) => {
if (err) {
console.log('检查目录失败:', err.message);
conn.end();
return;
}
stream.on('data', (data) => {
console.log('目录内容:', data.toString());
});
stream.on('close', () => {
conn.exec('cd /www/huishou && cat docker-compose.yml', (err, stream2) => {
if (err) {
console.log('读取docker-compose.yml失败:', err.message);
conn.end();
return;
}
stream2.on('data', (data) => {
console.log('\ndocker-compose.yml:', data.toString());
});
stream2.on('close', () => {
conn.exec('cd /www/huishou && cat admin/nginx.conf 2>/dev/null || echo "nginx.conf不存在"', (err, stream3) => {
if (err) {
console.log('读取nginx.conf失败:', err.message);
conn.end();
return;
}
stream3.on('data', (data) => {
console.log('\nnginx.conf:', data.toString());
});
stream3.on('close', () => {
conn.exec('cd /www/huishou && docker-compose up 2>&1 | head -100', (err, stream4) => {
if (err) {
console.log('启动docker-compose失败:', err.message);
conn.end();
return;
}
stream4.on('data', (data) => {
console.log('\n启动日志:', data.toString());
});
stream4.on('close', () => {
conn.end();
});
});
});
});
});
});
});
});
});
conn.on('error', (err) => {
console.log('连接错误:', err.message);
});
conn.connect({
host: 'hs.yifenbao.cn',
port: 22,
username: 'root',
password: 'Torch1112'
});