mongotask

A tool for scheduled, queued, flow and cleanup background tasks in node.

Mongotask

Mongotask is a simple background task framework for NodeJS.

Mongotask allows you to queue any Mongoose object as a background task simply by setting what properties it needs to match.

Can also be used for one-off task queues, time-scheduled tasks, but is especially handy for doing routine cleanups & processing objects through successive stages in a distributed fashion

Requires Apache Zookeeper to operate in a cluster.

    // Require mongotask
    var mongotask = require('mongotask');
    
    // Create a configuration for the TaskManager
    var config = {
        zookeeper_enabled: false
    }
    
    // Create a TaskManager object
    var taskManager = new mongotask.TaskManager(config);
    
    // Configure a background task to be executed once a second (1000ms) 
    var taskConfig = {
        type: "interval",
        func: function(callback)
              {
                  console.log("A second has gone by!", 1000);
              }
    };
    
    // Register the task. It will now begin executing.
    taskManager.registerIntervalTask(taskConfig);
    
    // Start background tasks
    taskManager.start();