sidequest
Sidequest is simple background processor for node.js
It's the first task scheduler that you may add to your web application project with safety, by using child process or running on backgroun it wont block the main process, even with if the task use blocking io.
Usage
Tree steps to background tasks :rocket:
-
- Install sidequest dependency
npm install --save sidequest
const { Task } = require('sidequest');
class MyJob extends Task {
run(foo, bar){
console.log(foo, bar);
}
}
module.exports = MyJob;
-
- Create the
sidequest-config.json
and register your queues and tasks:
{
"queues": [
{
"name": "high",
"workers": 10
},
{
"name": "default",
"workers": 2
}
],
"tasks": [
{
"name": "MyJob",
"path": "./playground/my-job.js",
"queue": "high"
}
]
}
-
- Initialize
sidequest
in you app:
const sidequest = require('sidequest');
sidequest.start();
- Alternative: Start sidequest by command line:
$ npm install -g sidequest
$ sidequest