Initializer

ActionHero. Initializer

new Initializer()

Source:
Tutorials:
Properties:
Name Type Description
name string

The name of the Initializer.

loadPriority Number

What order should this Initializer load at (Default: 1000, ActionHero core methods are < 1000).

startPriority Number

What order should this Initializer start at (Default: 1000, ActionHero core methods are < 1000).

stopPriority Number

What order should this Initializer stop at (Default: 1000, ActionHero core methods are < 1000).

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

Example
const {Initializer, api} = require('actionhero')

module.exports = class MyCLICommand extends Initializer {
  constructor () {
    super()
    this.name = 'connectToDatabase'
    this.loadPriority = 1000
    this.startPriority = 1000
    this.stopPriority = 1000
  }

  async initialize () {
    api.connectToDatabase = {}
  }

  async start () {
    // connect
  }
  async stop () {
    // disconnect
  }
}

Methods

(async, static) initialize()

Source:

Method run as part of the initialize lifecycle of your server. Ususally sets api['YourNamespace']

(async, static) start()

Source:

Method run as part of the start lifecycle of your server. Ususally connects to remote servers or processes.

(async, static) stop()

Source:

Method run as part of the initialize lifecycle of your server. Ususally disconnects from remote servers or processes.