feat: watch latest.yml and emit force-update to clients
continuous-integration/webhook Deploy concluído (VPS4)

This commit is contained in:
VPS 4 Deploy Agent
2026-06-03 06:05:47 +02:00
parent 18bb8594b2
commit acf2712dc7
2 changed files with 22 additions and 2 deletions
@@ -1 +1 @@
2.1.67
2.1.68
+21 -1
View File
@@ -1511,8 +1511,28 @@ async function start() {
console.log(`🖼️ Processed at: ${PROCESSED_DIR}`);
console.log('═══════════════════════════════════════════════════════');
// Watch for client updates
try {
const updatesDir = path.join(__dirname, 'updates');
const fsSync = require('fs');
if (fsSync.existsSync(updatesDir)) {
let updateTimeout = null;
fsSync.watch(updatesDir, (eventType, filename) => {
if (filename === 'latest.yml') {
if (updateTimeout) clearTimeout(updateTimeout);
updateTimeout = setTimeout(() => {
console.log('📦 Nova atualização detectada em latest.yml. Notificando clientes...');
io.emit('force-update', { version: 'latest' });
}, 5000); // 5s debounce para dar tempo do .exe terminar de copiar
}
});
}
} catch (e) {
console.error('Erro ao configurar watcher de atualizações:', e.message);
}
const installedFile = path.join(__dirname, 'data', '.installed');
if (!fsSync.existsSync(installedFile)) {
if (!require('fs').existsSync(installedFile)) {
console.log('⚠️ Sistema não instalado. Acesse /install para configurar.');
}
});