stop method

Future<void> stop()

Stop the server gracefully, in every isolate:

  1. stop taking new connections
  2. wait for open requests, up to config.shutdownTimeout
  3. run shutdown() of every provider (eg. close database connections)
  4. close the cache stores (eg. Redis connections)

SIGTERM and SIGINT call this, then exit the process.

await Dox().stop();

Implementation

Future<void> stop() async {
  _cancelSignals();
  try {
    await Future.wait(<Future<void>>[
      _spawner.stopAll(config.shutdownTimeout),
      stopIsolate(),
    ]);
    // close the bus again: `killAll` closes it while the providers of the
    // main isolate still shut down, and one of them may join it again.
    IsolateBus.instance.close();
    // last: the other isolates may use it until they are done
    ComputePool.instance.close();
  } finally {
    LogBuffer.flush();
  }
}