Skip to content

Commit c23f599

Browse files
committed
Aborted jobs now automatically use the EmailRole job handler to email all admins.
1 parent 25011db commit c23f599

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

ving/docs/change-log.md

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ outline: deep
99
* Jobs now automatically retry 3 times and then are aborted.
1010
* Fixed: job runner not gracefully erroring #198
1111
* Added better documentation for the job handlers.
12+
* Added generic email template.
13+
* Added EmailRole job handler.
14+
* Aborted jobs now automatically use the EmailRole job handler to email all admins.
15+
* Fixed CLI docs for email.
16+
* Fixed the generator deployment location for email templates.
1217

1318
### 2025-01-14
1419
* Added VingRecord.describeLinks() to generate links for the UI rather than having to manually code them in a describe() override. They are automatically generated for all VingRecords via the CLI, and then pages that are generated also use the exposed links. #179

ving/jobs/worker.mjs

+11-1
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,20 @@ export class VingJobWorker {
5757
ving.log('jobs').info(`${job.id} ${job.name} has completed`);
5858
});
5959

60-
this.worker.on('failed', (job, err) => {
60+
this.worker.on('failed', async (job, err) => {
6161
ving.log('jobs').error(`${job.id} ${job.name} has errored with ${err.message} using data ${JSON.stringify(job.data)}`);
6262
if (job.attemptsMade >= job.opts.attempts) {
6363
ving.log('jobs').error(`CRITICAL: ${job.id} ${job.name} aborted after ${job.attemptsMade} attempts`);
64+
await ving.addJob('EmailRole', {
65+
role: 'admin',
66+
subject: `Job ${job.name} aborted`,
67+
message: `Job ${job.name} aborted after ${job.attemptsMade} attempts.
68+
69+
Job Id: ${job.id}
70+
Error: ${err.message}
71+
Data:
72+
${JSON.stringify(job.data)}`,
73+
});
6474
}
6575
});
6676
ving.log('jobs').info(`worker started`);

0 commit comments

Comments
 (0)