32 lines
688 B
JavaScript
32 lines
688 B
JavaScript
import { Client } from 'ssh2';
|
|
|
|
const conn = new Client();
|
|
|
|
conn.on('ready', () => {
|
|
console.log('=== 检查生效配置 ===\n');
|
|
|
|
conn.exec('/www/server/nginx/sbin/nginx -T 2>&1 | grep -B 2 -A 30 "server_name hs.yifenbao.cn"', (err, stream) => {
|
|
if (err) {
|
|
console.log('搜索失败:', err.message);
|
|
} else {
|
|
stream.on('data', (data) => {
|
|
console.log('生效配置:', data.toString());
|
|
});
|
|
}
|
|
|
|
stream.on('close', () => {
|
|
conn.end();
|
|
});
|
|
});
|
|
});
|
|
|
|
conn.on('error', (err) => {
|
|
console.log('连接错误:', err.message);
|
|
});
|
|
|
|
conn.connect({
|
|
host: 'hs.yifenbao.cn',
|
|
port: 22,
|
|
username: 'root',
|
|
password: 'Torch1112'
|
|
}); |