mongodb
Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user