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.
Tree steps to background tasks 🚀
-
- Install sidequest dependency
npm install --save sidequest
-
- Create a task class
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:
- Create the
{
"queues": [
{
"name": "high",
"workers": 10
},
{
"name": "default",
"workers": 2
}
],
"tasks": [
{
"name": "MyJob",
"path": "./playground/my-job.js",
"queue": "high"
}
]
}
-
- Initialize
sidequest
in you app:
- Initialize
const sidequest = require('sidequest');
// ...
sidequest.start();
// ...
- Alternative: Start sidequest by command line:
$ npm install -g sidequest
$ sidequest