Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
Omar Sánchez Pizarro
2026-01-20 03:21:50 +01:00
parent 19932854ca
commit 81bf0675ed
32 changed files with 3081 additions and 932 deletions

View File

@@ -1,34 +1,13 @@
import { watch } from 'chokidar';
import { existsSync } from 'fs';
import { PATHS } from '../config/constants.js';
import { readJSON } from '../utils/fileUtils.js';
import { broadcast } from './websocket.js';
// File watcher ya no es necesario ya que los workers se almacenan en MongoDB
// Los cambios se notifican directamente a través de WebSocket cuando se actualizan via API
let watcher = null;
// Inicializar file watcher
// Inicializar file watcher (ahora vacío, mantenido para compatibilidad)
export function initFileWatcher() {
// Watch files for changes
const filesToWatch = [PATHS.WORKERS].filter(p => existsSync(p));
if (filesToWatch.length === 0) {
return;
}
watcher = watch(filesToWatch, {
persistent: true,
ignoreInitial: true,
});
watcher.on('change', async (path) => {
console.log(`Archivo cambiado: ${path}`);
if (path === PATHS.WORKERS) {
const workers = readJSON(PATHS.WORKERS);
broadcast({ type: 'workers_updated', data: workers });
}
});
console.log('✅ File watcher inicializado');
// Los workers ahora se almacenan en MongoDB y se notifican directamente
// a través de WebSocket cuando se actualizan via API
console.log(' File watcher no es necesario (workers en MongoDB)');
}
// Detener file watcher