$callWebServerStart static method

Future<void> $callWebServerStart(
  1. Node node,
  2. NodeStorage storage,
  3. PrecisionStopwatch wallClock
)

Implementation

static Future<void> $callWebServerStart(
    Node node, NodeStorage storage, PrecisionStopwatch wallClock) async {
  if (node is WebServer) {
    if ((node as WebServer).$server != null) {
      node.logger.warn(
          "WebServer is already running! Trying to stop the old one first...");
      await (node as WebServer).$server?.close(force: false);
      (node as WebServer).$server = null;
      node.logger.warn("Stopped the old WebServer");
    }

    (node as WebServer).$server = await (node as WebServer)
        .onWebserverStart((node as Routing).$buildRouter);
    node.logger.info(
        "Started WebServer in ${wallClock.getMilliseconds().toStringAsFixed(0)}ms");
  }
}