|
|
|
|
@ -66,6 +66,8 @@ export class GroupSyncService {
|
|
|
|
|
return interval;
|
|
|
|
|
}
|
|
|
|
|
private static lastSyncAttempt = 0;
|
|
|
|
|
private static _groupsTimer: any = null;
|
|
|
|
|
private static _groupsSchedulerRunning = false;
|
|
|
|
|
private static _membersTimer: any = null;
|
|
|
|
|
private static _membersSchedulerRunning = false;
|
|
|
|
|
|
|
|
|
|
@ -615,6 +617,35 @@ export class GroupSyncService {
|
|
|
|
|
this.cacheActiveGroups();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static startGroupsScheduler(): void {
|
|
|
|
|
if (process.env.NODE_ENV === 'test') return;
|
|
|
|
|
if (this._groupsSchedulerRunning) return;
|
|
|
|
|
this._groupsSchedulerRunning = true;
|
|
|
|
|
|
|
|
|
|
// Intervalo de grupos configurable; mínimo 10s en desarrollo
|
|
|
|
|
let interval = Number(process.env.GROUP_SYNC_INTERVAL_MS);
|
|
|
|
|
if (!Number.isFinite(interval) || interval <= 0) {
|
|
|
|
|
interval = 24 * 60 * 60 * 1000; // 24h por defecto
|
|
|
|
|
}
|
|
|
|
|
if (process.env.NODE_ENV === 'development' && interval < 10000) {
|
|
|
|
|
interval = 10000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._groupsTimer = setInterval(() => {
|
|
|
|
|
this.syncGroups().catch(err => {
|
|
|
|
|
console.error('❌ Groups scheduler run error:', err);
|
|
|
|
|
});
|
|
|
|
|
}, interval);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static stopGroupsScheduler(): void {
|
|
|
|
|
this._groupsSchedulerRunning = false;
|
|
|
|
|
if (this._groupsTimer) {
|
|
|
|
|
clearInterval(this._groupsTimer);
|
|
|
|
|
this._groupsTimer = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static startMembersScheduler(): void {
|
|
|
|
|
if (process.env.NODE_ENV === 'test') return;
|
|
|
|
|
if (this._membersSchedulerRunning) return;
|
|
|
|
|
|