mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 05:50:35 +03:00
b0581c778e
refs https://github.com/TryGhost/Toolbox/issues/357 - Job persisted in the database need to track job's execution status such as completion, failure, execution start and end times. This changeset allows to hook into job/bree lifecycle to track job's progress. - NOTE: only supports "offloaded" jobs at the moment. Support for "inline" jobs will be added once there's a clear usecase for it. - The "started" status and "started_at" timestamp are assigned to a job at the moment when the worker thread is created inside of bree - The "finished" status and "finished_at" timestamp are assigned to a job when a "done" event is passed from the job script (NOTE: using process.exit(0) will not trigger the "finished" state") - The "failed" status is assigned when the job execution is interrupted with an error
24 lines
424 B
JavaScript
24 lines
424 B
JavaScript
class JobsRepository {
|
|
constructor({JobModel}) {
|
|
this._JobModel = JobModel;
|
|
}
|
|
|
|
async add(data) {
|
|
const job = await this._JobModel.add(data);
|
|
|
|
return job;
|
|
}
|
|
|
|
async read(name) {
|
|
const job = await this._JobModel.findOne({name});
|
|
|
|
return job;
|
|
}
|
|
|
|
async update(id, data) {
|
|
await this._JobModel.edit(data, {id});
|
|
}
|
|
}
|
|
|
|
module.exports = JobsRepository;
|