itask
v1.0.1
Published
### Installation
Downloads
5
Readme
Simple Tasks Manager
Installation
$ npm install itask
Usage
// my-task.js
const {Task} = require('itask')
module.exports = class MyTask extends Task{
start(data){
console.log('my-task.js started', data)
setTimeout(() => {
this.finish(null, 'mydata')
}, 1000)
}
end(error, data){
console.log('my-task.js ended', error || data)
}
}
// index.js
const {TaskManager} = require('itask')
TaskManager.start(`${__dirname}/my-task.js`, {
timeout: 3000,
// data to be passed to the task
data: {
a: 1,
b: 2
},
// chamado imediatamente após iniciar a tarefa
init(error, uid, out){
console.log(error || uid)
}
})
// getting the log
// console.log(TaskManager.log('cec90de9fa02'))