Initial commit - full huishou project

This commit is contained in:
jiapengyu
2026-07-27 14:07:26 +08:00
commit 60790ad1b3
39127 changed files with 5989265 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
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=== 检查配置文件权限 ===');
await executeCommand('ls -la /www/server/panel/vhost/nginx/hs.yifenbao.cn.conf');
console.log('\n=== 重启Nginx ===');
await executeCommand('/www/server/nginx/sbin/nginx -s stop && sleep 2 && /www/server/nginx/sbin/nginx');
console.log('\n=== 等待Nginx启动 ===');
await sleep(5000);
console.log('\n=== 测试H5访问 ===');
await executeCommand('curl -s http://localhost/h5/');
console.log('\n=== 测试完整H5页面 ===');
await executeCommand('curl -s http://hs.yifenbao.cn/h5/');
} 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());
});
});
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
conn.on('error', (err) => {
console.error('SSH连接错误:', err.message);
});
conn.connect(config);