Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4793027ff3 | |||
| 38532a6296 | |||
| aa5ea72e3b | |||
| e077442340 | |||
| 82506a74e8 | |||
| cae02cb0f8 |
10
package.json
10
package.json
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "esqueue",
|
"name": "esqueue",
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"description": "",
|
"description": "Job queue, powered by Elasticsearch",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rm -rf lib && babel src --out-dir lib",
|
"build": "rm -rf lib && babel src --out-dir lib",
|
||||||
@@ -11,6 +11,12 @@
|
|||||||
"unit": "nyc --require babel-core/register mocha test/src/**"
|
"unit": "nyc --require babel-core/register mocha test/src/**"
|
||||||
},
|
},
|
||||||
"author": "Joe Fleming (https://github.com/w33ble)",
|
"author": "Joe Fleming (https://github.com/w33ble)",
|
||||||
|
"keywords": [
|
||||||
|
"job",
|
||||||
|
"queue",
|
||||||
|
"worker",
|
||||||
|
"elasticsearch"
|
||||||
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/w33ble/esqueue.git"
|
"url": "https://github.com/w33ble/esqueue.git"
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export default class Job extends events.EventEmitter {
|
|||||||
payload: this.payload,
|
payload: this.payload,
|
||||||
priority: this.priority,
|
priority: this.priority,
|
||||||
timeout: this.timeout,
|
timeout: this.timeout,
|
||||||
|
process_expiration: new Date(0), // use epoch so the job query works
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
attempts: 0,
|
attempts: 0,
|
||||||
max_attempts: this.maxAttempts,
|
max_attempts: this.maxAttempts,
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export default class Job extends events.EventEmitter {
|
|||||||
this.debug = (...msg) => debug(...msg, `id: ${this.id}`);
|
this.debug = (...msg) => debug(...msg, `id: ${this.id}`);
|
||||||
|
|
||||||
this._checker = false;
|
this._checker = false;
|
||||||
|
this.debug(`Created worker for type ${this.type}`);
|
||||||
this._startJobPolling();
|
this._startJobPolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +119,8 @@ export default class Job extends events.EventEmitter {
|
|||||||
const workerOutput = new Promise((resolve, reject) => {
|
const workerOutput = new Promise((resolve, reject) => {
|
||||||
resolve(this.workerFn.call(null, job._source.payload));
|
resolve(this.workerFn.call(null, job._source.payload));
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
|
this.debug(`Timeout processing job ${job._id}`);
|
||||||
reject(new WorkerTimeoutError({
|
reject(new WorkerTimeoutError({
|
||||||
timeout: job._source.timeout,
|
timeout: job._source.timeout,
|
||||||
jobId: job._id,
|
jobId: job._id,
|
||||||
@@ -148,7 +150,8 @@ export default class Job extends events.EventEmitter {
|
|||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
if (err.statusCode === 409) return false;
|
if (err.statusCode === 409) return false;
|
||||||
throw err;
|
this.debug(`Failure saving job output ${job._id}`, err);
|
||||||
|
this.emit('job_error', err);
|
||||||
});
|
});
|
||||||
}, (jobErr) => {
|
}, (jobErr) => {
|
||||||
// job execution failed
|
// job execution failed
|
||||||
@@ -158,7 +161,7 @@ export default class Job extends events.EventEmitter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.debug(`Failure occurred on job ${job._id}`);
|
this.debug(`Failure occurred on job ${job._id}`, jobErr);
|
||||||
this.emit('job_error', jobErr);
|
this.emit('job_error', jobErr);
|
||||||
return this._failJob(job, jobErr.toString());
|
return this._failJob(job, jobErr.toString());
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user