From 082d3cece0812ed53f24d33e206a27ebd15d6e3f Mon Sep 17 00:00:00 2001 From: Kevin Aleman Date: Thu, 19 Dec 2024 09:10:51 -0600 Subject: [PATCH] fix: Start cronjobs after the database has been migrated (#34215) --- .changeset/lucky-wolves-turn.md | 5 +++++ apps/meteor/server/startup/cron.ts | 8 +++----- apps/meteor/server/startup/index.ts | 4 +++- 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .changeset/lucky-wolves-turn.md diff --git a/.changeset/lucky-wolves-turn.md b/.changeset/lucky-wolves-turn.md new file mode 100644 index 000000000000..0dbb08af9e0f --- /dev/null +++ b/.changeset/lucky-wolves-turn.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +Fixes a UI issue that showed the incorrect migration number on the `Information` page. This was caused by a function calculating the stats before the server had migrated the database and updated the control. diff --git a/apps/meteor/server/startup/cron.ts b/apps/meteor/server/startup/cron.ts index 308d1297a01a..8951038f80fe 100644 --- a/apps/meteor/server/startup/cron.ts +++ b/apps/meteor/server/startup/cron.ts @@ -1,5 +1,4 @@ import { Logger } from '@rocket.chat/logger'; -import { Meteor } from 'meteor/meteor'; import { federationCron } from '../cron/federation'; import { npsCron } from '../cron/nps'; @@ -12,14 +11,13 @@ import { videoConferencesCron } from '../cron/videoConferences'; const logger = new Logger('SyncedCron'); -Meteor.defer(async () => { +export const startCronJobs = async (): Promise => { await startCron(); - await oembedCron(); await usageReportCron(logger); await npsCron(); await temporaryUploadCleanupCron(); await federationCron(); await videoConferencesCron(); - await userDataDownloadsCron(); -}); + userDataDownloadsCron(); +}; diff --git a/apps/meteor/server/startup/index.ts b/apps/meteor/server/startup/index.ts index 001af2c12be5..048735bba752 100644 --- a/apps/meteor/server/startup/index.ts +++ b/apps/meteor/server/startup/index.ts @@ -1,6 +1,6 @@ import './appcache'; import './callbacks'; -import './cron'; +import { startCronJobs } from './cron'; import './initialData'; import './serverRunning'; import './coreApps'; @@ -13,6 +13,8 @@ import { isRunningMs } from '../lib/isRunningMs'; export const startup = async () => { await performMigrationProcedure(); + + setImmediate(() => startCronJobs()); // only starts network broker if running in micro services mode if (!isRunningMs()) { require('./localServices');