@@ -35,6 +35,7 @@ import { Repl as ReplApp } from '#src/applications/Repl'
3535import { parse as semverParse , satisfies as semverSatisfies } from 'semver'
3636import { Is , Path , File , Module , Options , Macroable } from '@athenna/common'
3737import { NotSatisfiedNodeVersion } from '#src/exceptions/NotSatisfiedNodeVersion'
38+ import { debug } from '#src/debug/index'
3839
3940export class Ignite extends Macroable {
4041 /**
@@ -57,6 +58,11 @@ export class Ignite extends Macroable {
5758 */
5859 public options : IgniteOptions
5960
61+ /**
62+ * Holds if Ignite has already been fired.
63+ */
64+ public hasFired : boolean = false
65+
6066 /**
6167 * Install source maps support if the --enable-source-maps
6268 * flag is not set.
@@ -167,7 +173,7 @@ export class Ignite extends Macroable {
167173 try {
168174 this . options . environments . push ( 'http' )
169175
170- await this . fire ( )
176+ await this . fire ( options ?. forceIgniteFire )
171177
172178 return await Http . boot ( options )
173179 } catch ( err ) {
@@ -182,7 +188,7 @@ export class Ignite extends Macroable {
182188 try {
183189 this . options . environments . push ( 'cron' )
184190
185- await this . fire ( )
191+ await this . fire ( options ?. forceIgniteFire )
186192
187193 return await Cron . boot ( options )
188194 } catch ( err ) {
@@ -197,7 +203,7 @@ export class Ignite extends Macroable {
197203 try {
198204 this . options . environments . push ( 'worker' )
199205
200- await this . fire ( )
206+ await this . fire ( options ?. forceIgniteFire )
201207
202208 return await Worker . boot ( options )
203209 } catch ( err ) {
@@ -209,7 +215,17 @@ export class Ignite extends Macroable {
209215 * Fire the application configuring the env variables file, configuration files
210216 * providers and preload files.
211217 */
212- public async fire ( ) {
218+ public async fire ( forceIgniteFire ?: boolean ) {
219+ if ( this . hasFired && ! forceIgniteFire ) {
220+ debug (
221+ 'application already fired. if you need to refire use forceIgniteFire option in your application bootstrap.'
222+ )
223+
224+ return
225+ }
226+
227+ this . hasFired = true
228+
213229 try {
214230 this . setEnvVariablesFile ( )
215231 await this . setConfigurationFiles ( )
0 commit comments