shutdown method

Future<void> shutdown(
  1. Duration timeout
)

Graceful stop: no new connections, open requests get timeout to finish. Then every connection is closed.

Implementation

Future<void> shutdown(Duration timeout) async {
  HttpServer server = httpServer;
  // completes when the open requests are done. WebSockets get 1001.
  await server.close().then(_ignore).timeout(timeout, onTimeout: _nothing);
  await server.close(force: true);
}