chore: merge quick task worktree (worktree-agent-aed3ab3e5ca2a6fb2)
This commit is contained in:
commit
db7db98374
2 changed files with 45 additions and 1 deletions
|
|
@ -22,7 +22,7 @@ export interface ScheduleConfig {
|
|||
name: string;
|
||||
description: string;
|
||||
cron_expression: string;
|
||||
sync_type: 'incremental' | 'full' | 'veeam-incremental' | 'veeam-full' | 'veeam-rpo-check' | 'contract-services' | 'engagement-daily' | 'zoom-daily' | 'morning-summary' | 'ticket-digest-daily' | 'ticket-digest-weekly' | 'ticket-digest-monthly' | 'device-link-reconcile' | 'integration-health' | 'qbo' | 'appgate-sessions' | 'appgate-daily' | 'tickets-reconcile' | 'pax8-daily' | 'phishing-sweep';
|
||||
sync_type: 'incremental' | 'full' | 'veeam-incremental' | 'veeam-full' | 'veeam-rpo-check' | 'contract-services' | 'engagement-daily' | 'zoom-daily' | 'morning-summary' | 'ticket-digest-daily' | 'ticket-digest-weekly' | 'ticket-digest-monthly' | 'device-link-reconcile' | 'integration-health' | 'qbo' | 'mimecast-sync' | 'appgate-sessions' | 'appgate-daily' | 'tickets-reconcile' | 'pax8-daily' | 'phishing-sweep';
|
||||
years_back?: number;
|
||||
is_enabled: boolean;
|
||||
last_run?: Date;
|
||||
|
|
@ -491,6 +491,28 @@ class SyncScheduler {
|
|||
await getPax8SyncService().fullSync('scheduled');
|
||||
}
|
||||
}
|
||||
} else if (config.sync_type === 'mimecast-sync') {
|
||||
const { isMimecastConfigured } = await import('@/lib/services/mimecast-client');
|
||||
if (!isMimecastConfigured()) {
|
||||
console.log('[SCHEDULER] Skipping mimecast-sync — Mimecast not configured');
|
||||
} else {
|
||||
const { runMimecastIncrementalSync } = await import('@/lib/services/mimecast-sync-service');
|
||||
const result = await runMimecastIncrementalSync();
|
||||
console.log(
|
||||
`[SCHEDULER] mimecast-sync: messagesUpserted=${result.messagesUpserted} threatsUpserted=${result.threatsUpserted} bodiesFetched=${result.bodiesFetched} purgedMessages=${result.purgedMessages} errors=${result.errors.length} durationMs=${result.durationMs}`
|
||||
);
|
||||
}
|
||||
} else if (config.sync_type === 'qbo') {
|
||||
const disabledRes = await postgresClient.query<{ disabled: boolean }>(
|
||||
`SELECT disabled FROM integration_settings WHERE key = 'qbo'`
|
||||
);
|
||||
const isDisabled = disabledRes.rows[0]?.disabled === true;
|
||||
if (isDisabled) {
|
||||
console.log('[SCHEDULER] Skipping qbo sync — QBO disabled via /admin/integrations');
|
||||
} else {
|
||||
const { getQboSyncService } = await import('@/lib/services/qbo-sync-service');
|
||||
await getQboSyncService().incrementalSync('scheduled');
|
||||
}
|
||||
} else if (config.sync_type === 'incremental') {
|
||||
await this.syncService.incrementalSync('scheduled');
|
||||
} else {
|
||||
|
|
|
|||
22
migrations/101_reschedule_mimecast_sync.sql
Normal file
22
migrations/101_reschedule_mimecast_sync.sql
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
-- Migration 101: Reschedule mimecast-sync off the 0 2 * * * cron collision.
|
||||
--
|
||||
-- mimecast-sync was seeded at '0 2 * * *', the same slot as qbo-sync-2am and
|
||||
-- veeam-full. Because the sync-scheduler dispatch table had no branches for
|
||||
-- 'mimecast-sync' or 'qbo' (fixed alongside this migration), both jobs were
|
||||
-- silently falling through to the generic Autotask fullSync() catch-all,
|
||||
-- which meant they never ran their real sync logic AND contended with
|
||||
-- veeam-full for the SyncService singleton mutex — producing
|
||||
-- "A sync operation is already in progress" lock errors at 2 AM.
|
||||
--
|
||||
-- Moves mimecast-sync to 4:45 AM (minute 45 is unused anywhere in the live
|
||||
-- sync_schedules table — avoids 0 4 (contract-services, pax8-daily), 30 4
|
||||
-- (tickets-reconcile), the 15 * * * * hourly device-link job, and the
|
||||
-- */30 :00/:30 veeam jobs).
|
||||
--
|
||||
-- Guarded on the stale cron value so this is a no-op if already moved (safe
|
||||
-- to re-run) and won't clobber an admin's manual schedule change made via
|
||||
-- /admin after this ships.
|
||||
|
||||
UPDATE sync_schedules
|
||||
SET cron_expression = '45 4 * * *', updated_at = NOW()
|
||||
WHERE id = 'mimecast-sync' AND cron_expression = '0 2 * * *';
|
||||
Loading…
Add table
Add a link
Reference in a new issue