feat: watch latest.yml and emit force-update to clients
continuous-integration/webhook Deploy concluído (VPS4)
continuous-integration/webhook Deploy concluído (VPS4)
This commit is contained in:
@@ -1 +1 @@
|
|||||||
2.1.67
|
2.1.68
|
||||||
|
|||||||
+21
-1
@@ -1511,8 +1511,28 @@ async function start() {
|
|||||||
console.log(`🖼️ Processed at: ${PROCESSED_DIR}`);
|
console.log(`🖼️ Processed at: ${PROCESSED_DIR}`);
|
||||||
console.log('═══════════════════════════════════════════════════════');
|
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');
|
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.');
|
console.log('⚠️ Sistema não instalado. Acesse /install para configurar.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user