Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: maintenance mode disables scheduler #3854

Merged
merged 2 commits into from
May 24, 2023

Conversation

kwasniew
Copy link
Contributor

@kwasniew kwasniew commented May 24, 2023

About the changes

  • adding ability to pause and resume the scheduler service. In a paused mode scheduler performs a no-op
  • pausing scheduler on application startup when maintenence mode is on
  • flipping maintenance mode at runtime affects the scheduler pause/resume

Important files

Discussion points

@vercel
Copy link

vercel bot commented May 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) May 24, 2023 10:00am
unleash-monorepo-frontend ⬜️ Ignored (Inspect) May 24, 2023 10:00am


return logger;
return { logger, getRecords };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing structure to fix TS errors

const schedulerService = new SchedulerService(logger);
const job = jest.fn();

schedulerService.pause();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pause will prevent immediate run and scheduled run

constructor(
{
patStore,
eventStore,
}: Pick<IUnleashStores, 'patStore' | 'eventStore'>,
config: IUnleashConfig,
settingService: SettingService,
schedulerService: SchedulerService,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new explicit dependency so that maintenance mode can affect the scheduler

@@ -51,6 +56,11 @@ export default class MaintenanceService {
setting: MaintenanceSchema,
user: string,
): Promise<void> {
if (setting.enabled) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the core of the logic for the runtime behavior

} = services;

if (await maintenanceService.isMaintenanceMode()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the core of the logic for the startup behavior

@@ -43,7 +43,7 @@ async function createApp(
const db = createDb(config);
const stores = createStores(config, db);
const services = createServices(stores, config, db);
scheduleServices(services);
await scheduleServices(services);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waiting on maintenance mode telling us if it's on/off

@@ -1,12 +1,17 @@
import { Logger, LogProvider } from '../logger';

export type SchedulerMode = 'active' | 'paused';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scheduler can be in paused mode now

Copy link
Contributor

@sjaanus sjaanus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@kwasniew kwasniew merged commit 5ac5753 into main May 24, 2023
8 checks passed
@kwasniew kwasniew deleted the maintenance-mode-disables-scheduler branch May 24, 2023 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants