Skip to main content
The Ignitor class is the main entry point for creating and managing AdonisJS application processes. It is used to instantiate an AdonisJS application in different known environments such as web servers, console commands, and test runners.

Import

import { Ignitor } from '@adonisjs/core'

Constructor

Creates a new Ignitor instance.
const ignitor = new Ignitor(appRoot, options)
appRoot
URL
required
The root URL of the application. Typically created using new URL(import.meta.url).
options
IgnitorOptions
Configuration options for the ignitor.

Methods

createApp

Creates an instance of the AdonisJS application for a specific environment.
const app = ignitor.createApp(environment)
environment
AppEnvironments
required
The environment in which to create the app. Valid values are:
  • 'web' - For HTTP server processes
  • 'console' - For Ace CLI commands
  • 'test' - For test runner processes
  • 'repl' - For REPL sessions
return
ApplicationService
Returns an instance of the Application class with all container bindings registered.

getApp

Retrieve the application instance created by the ignitor.
const app = ignitor.getApp()
return
ApplicationService | undefined
Returns the application instance if it has been created, otherwise undefined.

tap

Register a callback to access the application instance immediately after it is created.
ignitor.tap((app) => {
  // Configure or customize the app
})
callback
(app: ApplicationService) => void
required
Callback function that receives the application instance. Can be synchronous or asynchronous.
return
this
Returns the Ignitor instance for method chaining.

httpServer

Get an instance of the HTTP server process for running web applications.
const httpProcess = ignitor.httpServer()
return
HttpServerProcess
Returns a new HttpServerProcess instance that can be used to start the HTTP server.

ace

Get an instance of the Ace process for running CLI commands.
const aceProcess = ignitor.ace()
return
AceProcess
Returns a new AceProcess instance that can be used to handle command line arguments.

testRunner

Get an instance of the test runner process for running tests.
const testProcess = ignitor.testRunner()
return
TestRunnerProcess
Returns a new TestRunnerProcess instance that can be used to run test suites.

terminate

Terminates the application by calling the app.terminate() method.
await ignitor.terminate()
return
Promise<void>
Returns a promise that resolves when the application has been terminated.

Usage Examples

Starting an HTTP Server

import { Ignitor } from '@adonisjs/core'

const ignitor = new Ignitor(new URL(import.meta.url))

await ignitor.httpServer().start()

Running CLI Commands

import { Ignitor } from '@adonisjs/core'

const ignitor = new Ignitor(new URL(import.meta.url))

await ignitor.ace().handle(process.argv.slice(2))

Running Tests

import { Ignitor } from '@adonisjs/core'

const ignitor = new Ignitor(new URL(import.meta.url))

await ignitor.testRunner().run(async (app) => {
  // Your test code here
})

Using tap for Configuration

import { Ignitor } from '@adonisjs/core'

const ignitor = new Ignitor(new URL(import.meta.url))

ignitor.tap((app) => {
  // Configure the app before it starts
  console.log('App created in', app.environment, 'environment')
})

await ignitor.httpServer().start()

Process Classes

HttpServerProcess

The HTTP server process manages the Node.js HTTP server lifecycle.

start

Starts the HTTP server and wires up the application.
await httpProcess.start(serverCallback?)
serverCallback
(handler: RequestHandler) => Server
Optional callback to create a custom HTTP server instance. Useful for HTTPS or custom server configurations.

AceProcess

The Ace process manages CLI command execution.

configure

Register a callback to configure the Ace kernel before handling commands.
aceProcess.configure((app) => {
  // Configure ace kernel
})
callback
(app: ApplicationService) => void | Promise<void>
required
Configuration callback function.

handle

Handles command line arguments and executes matching Ace commands.
await aceProcess.handle(argv)
argv
string[]
required
Command line arguments array, typically process.argv.slice(2).

TestRunnerProcess

The test runner process manages the test environment lifecycle.

configure

Register a callback that runs after booting the app and before the provider’s ready hook.
testProcess.configure((app) => {
  // Configure test environment
})
callback
(app: ApplicationService) => void | Promise<void>
required
Configuration callback function.

run

Runs a callback after starting the app.
await testProcess.run(async (app) => {
  // Run your tests
})
callback
(app: ApplicationService) => void | Promise<void>
required
Test execution callback function.