From cae02cb0f825ede9f3aea2cf2fba01c7641cbfdb Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 10 May 2016 14:12:36 -0700 Subject: [PATCH 1/6] add description and keywords --- package.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 324ce03..16057b3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "esqueue", "version": "0.2.1", - "description": "", + "description": "Job queue, powered by Elasticsearch", "main": "lib/index.js", "scripts": { "build": "rm -rf lib && babel src --out-dir lib", @@ -11,6 +11,12 @@ "unit": "nyc --require babel-core/register mocha test/src/**" }, "author": "Joe Fleming (https://github.com/w33ble)", + "keywords": [ + "job", + "queue", + "worker", + "elasticsearch" + ], "repository": { "type": "git", "url": "https://github.com/w33ble/esqueue.git" From 82506a74e8f6584fb38991621375fac01d55cdc3 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 10 May 2016 16:01:24 -0700 Subject: [PATCH 2/6] set process_expiration by default without this, the job query fails with field='process_expiration' is unrecognized --- src/job.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/job.js b/src/job.js index 5a81cbb..1a53e1e 100644 --- a/src/job.js +++ b/src/job.js @@ -36,6 +36,7 @@ export default class Job extends events.EventEmitter { payload: this.payload, priority: this.priority, timeout: this.timeout, + process_expiration: new Date(0), // use epoch so the job query works created_at: new Date(), attempts: 0, max_attempts: this.maxAttempts, From e077442340df4d94c005160d4107fd772f85fdfd Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 10 May 2016 16:57:40 -0700 Subject: [PATCH 3/6] add debugging on job timeout --- src/worker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/worker.js b/src/worker.js index 98b3346..64c6994 100644 --- a/src/worker.js +++ b/src/worker.js @@ -119,6 +119,7 @@ export default class Job extends events.EventEmitter { resolve(this.workerFn.call(null, job._source.payload)); setTimeout(function () { + this.debug(`Timeout processing job ${job._id}`); reject(new WorkerTimeoutError({ timeout: job._source.timeout, jobId: job._id, From aa5ea72e3b36aa7bf120303455fe585149141941 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 10 May 2016 17:24:05 -0700 Subject: [PATCH 4/6] swollow errors saving job output, include error in debugging output --- src/worker.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/worker.js b/src/worker.js index 64c6994..f2af1d7 100644 --- a/src/worker.js +++ b/src/worker.js @@ -149,7 +149,8 @@ export default class Job extends events.EventEmitter { }) .catch((err) => { if (err.statusCode === 409) return false; - throw err; + this.debug(`Failure saving job output ${job._id}`, err); + this.emit('job_error', err); }); }, (jobErr) => { // job execution failed @@ -159,7 +160,7 @@ export default class Job extends events.EventEmitter { return; } - this.debug(`Failure occurred on job ${job._id}`); + this.debug(`Failure occurred on job ${job._id}`, jobErr); this.emit('job_error', jobErr); return this._failJob(job, jobErr.toString()); }); From 38532a6296478c210269495688e85f75e45f6796 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 10 May 2016 17:28:27 -0700 Subject: [PATCH 5/6] fix scoping issue, add debugging on worker register --- src/worker.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/worker.js b/src/worker.js index f2af1d7..d90587a 100644 --- a/src/worker.js +++ b/src/worker.js @@ -26,6 +26,7 @@ export default class Job extends events.EventEmitter { this.debug = (...msg) => debug(...msg, `id: ${this.id}`); this._checker = false; + this.debug(`Created worker for type ${this.type}`); this._startJobPolling(); } @@ -118,7 +119,7 @@ export default class Job extends events.EventEmitter { const workerOutput = new Promise((resolve, reject) => { resolve(this.workerFn.call(null, job._source.payload)); - setTimeout(function () { + setTimeout(() => { this.debug(`Timeout processing job ${job._id}`); reject(new WorkerTimeoutError({ timeout: job._source.timeout, From 4793027ff36940c0190797a9491f2b473a250f37 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 10 May 2016 17:31:09 -0700 Subject: [PATCH 6/6] 0.2.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 16057b3..4d1ad12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "esqueue", - "version": "0.2.1", + "version": "0.2.2", "description": "Job queue, powered by Elasticsearch", "main": "lib/index.js", "scripts": {