Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/core",
"version": "5.30.0",
"version": "5.31.0",
"description": "One foundation for multiple applications.",
"license": "MIT",
"author": "João Lenon <lenon@athenna.io>",
Expand Down
24 changes: 20 additions & 4 deletions src/ignite/Ignite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { Repl as ReplApp } from '#src/applications/Repl'
import { parse as semverParse, satisfies as semverSatisfies } from 'semver'
import { Is, Path, File, Module, Options, Macroable } from '@athenna/common'
import { NotSatisfiedNodeVersion } from '#src/exceptions/NotSatisfiedNodeVersion'
import { debug } from '#src/debug/index'

export class Ignite extends Macroable {
/**
Expand All @@ -57,6 +58,11 @@ export class Ignite extends Macroable {
*/
public options: IgniteOptions

/**
* Holds if Ignite has already been fired.
*/
public hasFired: boolean = false

/**
* Install source maps support if the --enable-source-maps
* flag is not set.
Expand Down Expand Up @@ -167,7 +173,7 @@ export class Ignite extends Macroable {
try {
this.options.environments.push('http')

await this.fire()
await this.fire(options?.forceIgniteFire)

return await Http.boot(options)
} catch (err) {
Expand All @@ -182,7 +188,7 @@ export class Ignite extends Macroable {
try {
this.options.environments.push('cron')

await this.fire()
await this.fire(options?.forceIgniteFire)

return await Cron.boot(options)
} catch (err) {
Expand All @@ -197,7 +203,7 @@ export class Ignite extends Macroable {
try {
this.options.environments.push('worker')

await this.fire()
await this.fire(options?.forceIgniteFire)

return await Worker.boot(options)
} catch (err) {
Expand All @@ -209,7 +215,17 @@ export class Ignite extends Macroable {
* Fire the application configuring the env variables file, configuration files
* providers and preload files.
*/
public async fire() {
public async fire(forceIgniteFire?: boolean) {
if (this.hasFired && !forceIgniteFire) {
debug(
'application already fired. if you need to refire use forceIgniteFire option in your application bootstrap.'
)

return
}

this.hasFired = true

try {
this.setEnvVariablesFile()
await this.setConfigurationFiles()
Expand Down
9 changes: 9 additions & 0 deletions src/types/CronOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
*/

export type CronOptions = {
/**
* Force ignite to fire. If running multiple applications, Athenna will
* fire Ignite only on the first application bootstrap. Use this option
* if you want to force the Ignite fire for a specific application.
*
* @default false
*/
forceIgniteFire: boolean

/**
* The path to the cron routes.
*
Expand Down
9 changes: 9 additions & 0 deletions src/types/HttpOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
*/

export type HttpOptions = {
/**
* Force ignite to fire. If running multiple applications, Athenna will
* fire Ignite only on the first application bootstrap. Use this option
* if you want to force the Ignite fire for a specific application.
*
* @default false
*/
forceIgniteFire: boolean

/**
* Only initialize the server without booting it. Useful when you want to
* deploy your application in a serverless environment.
Expand Down
9 changes: 9 additions & 0 deletions src/types/WorkerOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
*/

export type WorkerOptions = {
/**
* Force ignite to fire. If running multiple applications, Athenna will
* fire Ignite only on the first application bootstrap. Use this option
* if you want to force the Ignite fire for a specific application.
*
* @default false
*/
forceIgniteFire: boolean

/**
* The path to the worker routes.
*
Expand Down
Loading