summaryrefslogtreecommitdiff
path: root/src/services/events
diff options
context:
space:
mode:
Diffstat (limited to 'src/services/events')
-rw-r--r--src/services/events/event.service.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/services/events/event.service.js b/src/services/events/event.service.js
index 235dc32..a8b0e72 100644
--- a/src/services/events/event.service.js
+++ b/src/services/events/event.service.js
@@ -22,9 +22,23 @@ class Events {
// Logs
- this.agenda.on('start', job => console.log(`Starting ${job.attrs.name} job`));
- this.agenda.on('complete', job => console.log(`Job ${job.attrs.name} finished`));
- this.agenda.on('fail', (err, job) => console.log(`Job failed with the error ${err}`));
+ this.agenda.on('start', job => {
+ console.log(`Starting ${job.attrs.data.name} job`);
+ job.attrs.status = 'running';
+ job.save();
+ });
+ this.agenda.on('complete', job => {
+ console.log(`Job ${job.attrs.data.name} finished`);
+ if (job.attrs.status === 'running') {
+ job.attrs.status = 'complete';
+ job.save();
+ }
+ });
+ this.agenda.on('fail', (err, job) => {
+ console.log(`Job ${job.attrs.data.name} failed with the error ${err.message}`);
+ job.attrs.status = 'failed';
+ job.save();
+ });
return this.agenda.start();
}