Subscribe to our list to receive the latest updates on Node on Fire

Class: Tasks

Tasks

new Tasks(app)

The tasks module. Useful to run one-off tasks in a cronjob or manually.

To create a task, create a constructor in the tasks/ folder with a run method:

function MyTask() {
    //
}
app.task(MyTask);

MyTask.prototype.run = function() {
    // do something
};

To invoke the task, execute the following: $ node index.js --task MyTask.

this.models and this.workers are available in your tasks.

Parameters:
Name Type Description
app App

Methods

run(taskNames)

Runs all the tasks in taskNames.

Parameters:
Name Type Description
taskNames Array:.<String:>

All the task names to run.

Returns:

Resolves with an array of promises via Q#all.

Type
Promise

setup(basePath)

Loads the tasks from the tasks/ folder.

Currently the tasks are always loaded even if no tasks are run.

Parameters:
Name Type Description
basePath String

The path to the app's directory.

start(argv)

Starts the tasks matching argv.name. See Tasks.

Parameters:
Name Type Description
argv Dictionary

The arguments passed to the process.

Returns:
Type
Promise

Do you have any questions or comments on this page? Start a discussion below.

comments powered by Disqus
Subscribe to our list to receive the latest updates on Node on Fire