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.

Constructors

  • 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.

    Returns Bootstrap

Properties

connections: Socket[] = []

Methods

  • 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.

  • 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.

  • 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.

  • 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.

  • 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.

    Returns void

    No value is returned.