ActionHero. Task

new Task()

Name Type Description
name string

The name of the Task.

description string

The description of the Task (default this.name).

frequency Number

How often to run this Task, in ms. 0 is non-recurring. (default: 0).

middleware Array

The Middleware specific to this Task (default: []). Middleware is descibed by the string names of the middleware.

queue string

The default queue to run this Task on (default: 'default').

Create a new ActionHero Task. The required properties of an task. These can be defined statically (this.name) or as methods which return a value.

'use strict'
const {Task, api} = require('actionhero')

module.exports = class SayHello extends Task {
 constructor () {
   this.name = 'sayHello'
   this.description = 'I say Hello every minute'
   this.frequency = (60 * 1000)

 async run (data, worker) {


(async, static) run(data, worker)


The main "do something" method for this task. It can be async. Anything returned from this metod will be logged. If error is thrown in this method, it will be logged & caught. Using middleware, you can decide to re-run the task on failure. this is a Task instance itself now.

Name Type Description
data Object

The data about this instance of the task, specifically params.

worker Object

Instance of a node-resque worker. You can inspect worker.job and set worker.result explicitly if your Task does not return a value.