diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/handlers/index.js | 2 | ||||
-rw-r--r-- | src/services/events/event.service.js | 20 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/handlers/index.js b/src/handlers/index.js index 658d8d9..09cd726 100644 --- a/src/handlers/index.js +++ b/src/handlers/index.js @@ -52,8 +52,6 @@ const handleJob = async job => { try { await Bluebird.map(participants, participant => handleJobAsUser(job, browser, participant)); - } catch (err) { - console.error(err); } finally { await browser.close(); } 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(); } |