arturo-server
Advanced tools
Comparing version 1.1.0 to 1.1.2
@@ -21,2 +21,6 @@ 'use strict'; | ||
var _moment = require('moment'); | ||
var _moment2 = _interopRequireDefault(_moment); | ||
var _nunjucks = require('nunjucks'); | ||
@@ -62,5 +66,11 @@ | ||
job.startDate = (0, _moment2.default)(job.startDate); | ||
job.finishDate = (0, _moment2.default)(job.finishDate); | ||
switch (job.status) { | ||
case 'completed': | ||
job.duration = _moment2.default.duration(job.finishDate.diff(job.startDate)).humanize(); | ||
break; | ||
case 'failed': | ||
job.duration = _moment2.default.duration((0, _moment2.default)(job.updatedAt).diff(job.initialDate)).humanize(); | ||
break; | ||
@@ -71,2 +81,5 @@ default: | ||
job.startDate = job.startDate.calendar(); | ||
job.finishDate = job.finishDate.calendar(); | ||
var title = job.route.replace(/\/(.)/g, function (m, c) { | ||
@@ -73,0 +86,0 @@ return ' ' + c.toUpperCase(); |
@@ -33,2 +33,11 @@ 'use strict'; | ||
_this.log = function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
args[0] = 'arturo:' + this.uuid + ' ' + args[0]; | ||
console.log.apply(console, args); | ||
}; | ||
_this.subprocess = opts.subprocess; | ||
@@ -61,3 +70,3 @@ _this.sequelize = opts.sequelize; | ||
if (this.cancelled) { | ||
this.debug(subprocess.pid + ' cancelling job #' + job.id + '...'); | ||
this.log(subprocess.pid + ' cancelling job #' + job.id + '...'); | ||
job.status = 'cancelled'; | ||
@@ -70,3 +79,3 @@ computaton.push(job); | ||
if (!subprocess.connected) { | ||
this.debug(subprocess.pid + ' worker unreachable: rescheduling job #' + job.id + '...'); | ||
this.log(subprocess.pid + ' worker unreachable: rescheduling job #' + job.id + '...'); | ||
var err = new Error('Worker Unreachable'); | ||
@@ -83,3 +92,3 @@ | ||
this.debug(subprocess.pid + ' processing job #' + job.id + '...'); | ||
this.log(subprocess.pid + ' processing job #' + job.id + '...'); | ||
@@ -93,3 +102,3 @@ job.status = 'processing'; | ||
clearListeners(); | ||
_this2.debug(subprocess.pid + ' worker interrupted: unable to finish job #' + job.id + '...'); | ||
_this2.log(subprocess.pid + ' worker interrupted: unable to finish job #' + job.id + '...'); | ||
var err = _this2.cancelled ? new Error('Worker Interrupted') : new Error('Worker Failure'); | ||
@@ -96,0 +105,0 @@ |
@@ -100,4 +100,2 @@ 'use strict'; | ||
console.log(env); | ||
WorkerManager.QUEUE.write({ | ||
@@ -104,0 +102,0 @@ path: dir, |
{ | ||
"name": "arturo-server", | ||
"version": "1.1.0", | ||
"version": "1.1.2", | ||
"description": "A database agnostic distributed job queue (server, client, and worker).", | ||
@@ -5,0 +5,0 @@ "main": "lib/server/index.js", |
import fs from 'fs' | ||
import path from 'path' | ||
import Debug from 'debug' | ||
import moment from 'moment' | ||
import nunjucks from 'nunjucks' | ||
@@ -25,5 +26,11 @@ import { debounce } from 'lodash' | ||
job.startDate = moment(job.startDate) | ||
job.finishDate = moment(job.finishDate) | ||
switch (job.status) { | ||
case 'completed': | ||
job.duration = moment.duration(job.finishDate.diff(job.startDate)).humanize() | ||
break; | ||
case 'failed': | ||
job.duration = moment.duration(moment(job.updatedAt).diff(job.initialDate)).humanize() | ||
break | ||
@@ -34,2 +41,5 @@ default: | ||
job.startDate = job.startDate.calendar() | ||
job.finishDate = job.finishDate.calendar() | ||
const title = job.route | ||
@@ -36,0 +46,0 @@ .replace(/\/(.)/g, (m, c) => ' ' + c.toUpperCase()) |
@@ -8,2 +8,7 @@ import Shutdown from './Shutdown' | ||
this.log = function (...args) { | ||
args[0] = `arturo:${this.uuid} ${args[0]}` | ||
console.log.apply(console, args) | ||
} | ||
this.subprocess = opts.subprocess | ||
@@ -28,3 +33,3 @@ this.sequelize = opts.sequelize | ||
if (this.cancelled) { | ||
this.debug(`${subprocess.pid} cancelling job #${job.id}...`) | ||
this.log(`${subprocess.pid} cancelling job #${job.id}...`) | ||
job.status = 'cancelled' | ||
@@ -37,3 +42,3 @@ computaton.push(job) | ||
if (!subprocess.connected) { | ||
this.debug(`${subprocess.pid} worker unreachable: rescheduling job #${job.id}...`) | ||
this.log(`${subprocess.pid} worker unreachable: rescheduling job #${job.id}...`) | ||
const err = new Error('Worker Unreachable') | ||
@@ -50,3 +55,3 @@ | ||
this.debug(`${subprocess.pid} processing job #${job.id}...`) | ||
this.log(`${subprocess.pid} processing job #${job.id}...`) | ||
@@ -60,3 +65,3 @@ job.status = 'processing' | ||
clearListeners() | ||
this.debug(`${subprocess.pid} worker interrupted: unable to finish job #${job.id}...`) | ||
this.log(`${subprocess.pid} worker interrupted: unable to finish job #${job.id}...`) | ||
const err = this.cancelled ? new Error('Worker Interrupted') : new Error('Worker Failure') | ||
@@ -63,0 +68,0 @@ |
@@ -38,4 +38,2 @@ import path from 'path' | ||
console.log(env) | ||
WorkerManager.QUEUE.write({ | ||
@@ -42,0 +40,0 @@ path: dir, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
331070
3618