The Bootstrap class is responsible for initializing, starting, stopping, and restarting
the application server. It manages the server lifecycle, client connections, and application
initialization. It also provides a mechanism for handling hot restarts.
Constructor for initializing the server application.
It sets up the Express application instance, initializes the counter
for hot restarts, sets the maximum number of allowed hot restarts,
and starts the server.
Restarts the application and server by stopping the current instance
and starting a new one. If the number of restarts exceeds the defined
maximum hot restarts threshold, the application forcibly shuts down.
Returns void
No return value.
startApplication
startApplication():void
Starts the application by performing the necessary initialization steps such as
resolving network addresses, logging initial status, and initializing dependency injection.
Returns void
This method does not return a value.
startServer
startServer():void
Starts the server by binding it to the specified port and initializing the application.
Sets up a listener for incoming connections and keeps track of active connections.
Returns void
Does not return a value.
stopApplication
stopApplication():void
Stops the application by invoking the onDestroy method on all instances where applicable.
It retrieves all injected instances and checks for the presence of an onDestroy method.
If found, the method is executed for proper cleanup.
Returns void
Does not return a value.
stopServer
stopServer():void
Stops the server and closes all active connections.
Ensures that all current connections are properly ended before shutting down the server.
Handles the case where the server instance exists by closing it gracefully.
The Bootstrap class is responsible for initializing, starting, stopping, and restarting the application server. It manages the server lifecycle, client connections, and application initialization. It also provides a mechanism for handling hot restarts.