stop method

Future stop()

Stops the application from running.

Closes every isolate and their channel and stops listening for HTTP requests. The ServiceRegistry will close any of its resources.

Implementation

Future stop() async {
  _hasFinishedLaunching = false;
  await Future.wait(supervisors.map((s) => s.stop()))
      .onError((error, stackTrace) {
    if (error.runtimeType.toString() == 'LateError') {
      throw StateError(
        'Channel type $T was not loaded in the current isolate. Check that the class was declared and public.',
      );
    }
    throw error! as Error;
  });

  try {
    await server.server.close(force: true);
  } catch (e) {
    logger.severe(e);
  }

  _hasFinishedLaunching = false;
  supervisors = [];

  logger.clearListeners();
}