diff --git a/src/lib/__snapshots__/create-config.test.ts.snap b/src/lib/__snapshots__/create-config.test.ts.snap index aef586cf9be8..5674c6cef574 100644 --- a/src/lib/__snapshots__/create-config.test.ts.snap +++ b/src/lib/__snapshots__/create-config.test.ts.snap @@ -44,6 +44,7 @@ exports[`should create default config 1`] = ` "user": "unleash", "version": undefined, }, + "disableScheduler": undefined, "email": { "host": undefined, "port": 587, diff --git a/src/lib/create-config.ts b/src/lib/create-config.ts index bf3a42ed3cef..ec57422d04d0 100644 --- a/src/lib/create-config.ts +++ b/src/lib/create-config.ts @@ -499,6 +499,7 @@ export function createConfig(options: IUnleashOptions): IUnleashConfig { accessControlMaxAge, prometheusApi, publicFolder: options.publicFolder, + disableScheduler: options.disableScheduler, }; } diff --git a/src/lib/server-impl.ts b/src/lib/server-impl.ts index 678e3c98ac52..2b59984822ee 100644 --- a/src/lib/server-impl.ts +++ b/src/lib/server-impl.ts @@ -43,7 +43,9 @@ async function createApp( const db = createDb(config); const stores = createStores(config, db); const services = createServices(stores, config, db); - await scheduleServices(services); + if (!config.disableScheduler) { + await scheduleServices(services); + } const metricsMonitor = createMetricsMonitor(); const unleashSession = sessionDb(config, db); diff --git a/src/lib/services/maintenance-service.test.ts b/src/lib/services/maintenance-service.test.ts index bcc7dd32d8a5..4eab1c0adcbc 100644 --- a/src/lib/services/maintenance-service.test.ts +++ b/src/lib/services/maintenance-service.test.ts @@ -24,7 +24,7 @@ test('Maintenance on should pause scheduler', async () => { }); test('Maintenance off should resume scheduler', async () => { - const config = createTestConfig(); + const config = createTestConfig({ disableScheduler: false }); const schedulerService = new SchedulerService(config.getLogger); schedulerService.pause(); const maintenanceService = new MaintenanceService( diff --git a/src/lib/services/maintenance-service.ts b/src/lib/services/maintenance-service.ts index ca99708fab38..21be7f12493a 100644 --- a/src/lib/services/maintenance-service.ts +++ b/src/lib/services/maintenance-service.ts @@ -58,7 +58,7 @@ export default class MaintenanceService { ): Promise { if (setting.enabled) { this.schedulerService.pause(); - } else { + } else if (!this.config.disableScheduler) { this.schedulerService.resume(); } return this.settingService.insert( diff --git a/src/lib/types/option.ts b/src/lib/types/option.ts index f3a2b7541345..533df4735217 100644 --- a/src/lib/types/option.ts +++ b/src/lib/types/option.ts @@ -118,6 +118,7 @@ export interface IUnleashOptions { accessControlMaxAge?: number; prometheusApi?: string; publicFolder?: string; + disableScheduler?: boolean; } export interface IEmailOption { @@ -207,4 +208,5 @@ export interface IUnleashConfig { accessControlMaxAge: number; prometheusApi?: string; publicFolder?: string; + disableScheduler?: boolean; } diff --git a/src/test/config/test-config.ts b/src/test/config/test-config.ts index 56f970a2fefe..4351eb322740 100644 --- a/src/test/config/test-config.ts +++ b/src/test/config/test-config.ts @@ -19,6 +19,7 @@ export function createTestConfig(config?: IUnleashOptions): IUnleashConfig { server: { secret: 'really-secret' }, session: { db: false }, versionCheck: { enable: false }, + disableScheduler: true, clientFeatureCaching: { enabled: false, }, diff --git a/src/test/e2e/helpers/test-helper.ts b/src/test/e2e/helpers/test-helper.ts index 7fbf6ee7c3d5..2941901bc855 100644 --- a/src/test/e2e/helpers/test-helper.ts +++ b/src/test/e2e/helpers/test-helper.ts @@ -179,6 +179,7 @@ async function createApp( server: { unleashUrl: 'http://localhost:4242', }, + disableScheduler: true, ...{ ...customOptions, experimental: {