mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 22:11:09 +03:00
Added defensive code for non-persistent job manager
refs https://github.com/TryGhost/Toolbox/issues/359 - It's up to a user to decide initializing the job manager without a "jobModel". In these cases the regular recurring job scheduling should work as it did before
This commit is contained in:
parent
9973b5419c
commit
822549c9ef
@ -66,10 +66,13 @@ class JobManager {
|
||||
this._jobMessageHandler({name, message: 'started'});
|
||||
});
|
||||
|
||||
if (JobModel) {
|
||||
this._jobsRepository = new JobsRepository({JobModel});
|
||||
}
|
||||
}
|
||||
|
||||
async _jobMessageHandler({name, message}) {
|
||||
if (this._jobsRepository) {
|
||||
if (message === 'started') {
|
||||
const job = await this._jobsRepository.read(name);
|
||||
|
||||
@ -90,9 +93,11 @@ class JobManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async _jobErrorHandler(error, workerMeta) {
|
||||
const job = await this._jobsRepository.read(workerMeta.name);
|
||||
async _jobErrorHandler(error, jobMeta) {
|
||||
if (this._jobsRepository) {
|
||||
const job = await this._jobsRepository.read(jobMeta.name);
|
||||
|
||||
if (job) {
|
||||
await this._jobsRepository.update(job.id, {
|
||||
@ -100,6 +105,7 @@ class JobManager {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* By default schedules an "offloaded" job. If `offloaded: true` parameter is set,
|
||||
|
Loading…
Reference in New Issue
Block a user