38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
const { Client } = require('ssh2');
|
|
|
|
const conn = new Client();
|
|
|
|
conn.on('ready', () => {
|
|
console.log('=== 验证服务器文件更新 ===');
|
|
|
|
// 检查weigh页面的JS文件
|
|
conn.exec('ls -la /www/huishou/dist/build/h5/assets/pages-weigh-weigh*.js', (err, stream) => {
|
|
if (err) { console.log('ERR:', err); }
|
|
else {
|
|
stream.on('data', (d) => console.log('weigh页面JS文件:', d.toString()));
|
|
}
|
|
stream.on('close', () => {
|
|
// 检查最新修改时间
|
|
conn.exec('stat /www/huishou/dist/build/h5/assets/pages-weigh-weigh*.js', (err2, stream2) => {
|
|
if (err2) { console.log('ERR2:', err2); }
|
|
else { stream2.on('data', (d2) => console.log('文件时间:', d2.toString())); }
|
|
stream2.on('close', () => {
|
|
// 强制清除浏览器缓存
|
|
conn.exec('touch /www/huishou/dist/build/h5/index.html', (err3) => {
|
|
if (err3) console.log('ERR3:', err3);
|
|
else console.log('已更新index.html时间戳');
|
|
|
|
// 重启nginx
|
|
conn.exec('/www/server/nginx/sbin/nginx -s reload', (err4) => {
|
|
if (err4) console.log('ERR4:', err4);
|
|
else console.log('Nginx已重启');
|
|
conn.end();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
conn.connect({ host: 'hs.yifenbao.cn', port: 22, username: 'root', password: 'Torch1112' }); |