Skip to content

Latest commit

 

History

History
69 lines (53 loc) · 1.14 KB

README.md

File metadata and controls

69 lines (53 loc) · 1.14 KB

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 🚀

    1. Install sidequest dependency
npm install --save sidequest
    1. Create a task class
const { Task } = require('sidequest');

class MyJob extends Task {
  run(foo, bar){
    console.log(foo, bar);
  }
}

module.exports = MyJob;
    1. 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"
    }
  ]
}
    1. Initialize sidequest in you app:
    const sidequest = require('sidequest');
    
    // ...
    sidequest.start();
    // ...
  • Alternative: Start sidequest by command line:
$ npm install -g sidequest
$ sidequest