Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion server/utils/BackgroundWorkers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ class BackgroundService {
*/
async #bootScheduledJobs() {
const { ScheduledJob } = require("../../models/scheduledJob");
const { SystemSettings } = require("../../models/systemSettings");

// Scheduled jobs are only available in single-user mode.
if (await SystemSettings.isMultiUserMode()) return;

const enabledJobs = await ScheduledJob.allEnabled();

for (const job of enabledJobs) {
Expand Down Expand Up @@ -373,10 +378,18 @@ class BackgroundService {
*
* @param {number} jobId - scheduled_jobs.id
* @returns {Promise<object|null>} the created run row, or null if skipped
* because a run is already in flight for this job.
* because a run is already in flight for this job or the instance is in
* multi-user mode.
*/
async enqueueScheduledJob(jobId) {
const { ScheduledJobRun } = require("../../models/scheduledJobRun");
const { SystemSettings } = require("../../models/systemSettings");

// Timers registered before the switch to multi-user mode stop here.
if (await SystemSettings.isMultiUserMode()) {
this.removeScheduledJob(jobId);
return null;
}

const run = await ScheduledJobRun.start(jobId);
// if start returns null, skip enqueuing, schueduled job already has a run in flight
Expand Down
Loading