Closed hphirke closed 6 years ago
Hi, you should be able to use jc.events
to do that.
https://github.com/vsivsi/meteor-job-collection/blob/master/README.md#jcevents---server-only
You should be able to easily add an event handler for jobFail
.
Then you just need a simple test to inspect why the job failed. The workTimeout
failure message is hard coded here:
https://github.com/vsivsi/meteor-job-collection/blob/master/src/server.coffee#L195
So the test will be something like:
if (msg.params[2].value === "Failed for exceeding worker set workTimeout") {
// Do something for this failed job.
}
Alternatively, you could set up a Meteor observe on the job collection and use a query to pick up newly failed jobs with a failure object value
matching that string.
Hope that helps.
Another quick tip... Inside of the event handler, msg.connection
will be undefined
for any events triggered by server-side code. So if you have no workers running in the server code, and no other custom logic that could cause a job to fail server-side, then you can dispense with testing for that magic string and just act on any jobFail
event with an undefined connection attribute.
jc.events and logic around own failure vs timeout failure did the trick for me. thanks
For the jobs I use workTimeout. Sometimes the job (external network where I am connecting) never comes back and workTimeout is triggered.
Is there a way I know that the job has failed due to workTimeout?
Basically I would like to update my database that the job failed. I don't know the event/callback I will get when job is failed due to workTimeout