Skip to content

Commit

Permalink
Make the node call listenHTTP first
Browse files Browse the repository at this point in the history
The runTask() call will spawn a new fiber and
and switch to the new fiber immediately.
However we want to start listening for incoming
requests before doing network discovery.

Using setTimer with a zero timeout (a.k.a. schedule())
makes the node open a listening port right away,
rather than waiting for the first discovery round
to complete.

It increases the node's connectivity to other nodes
which may want to establish a connection,
and consequently reduces CI failures.

Part of: #1117
  • Loading branch information
AndrejMitrovic committed Aug 14, 2020
1 parent 274b73b commit afc4cf5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion source/agora/node/Runner.d
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ import agora.utils.Log;

import ocean.util.log.ILogger;

import vibe.core.core;
import vibe.http.server;
import vibe.http.router;
import vibe.web.rest;

import std.file;
import std.format;

import core.time;

mixin AddLogger!();

/*******************************************************************************
Expand Down Expand Up @@ -86,7 +89,7 @@ public FullNode runNode (Config config)
res.writeVoidBody();
});

node.start(); // asynchronous
setTimer(0.seconds, &node.start, false); // asynchronous

log.info("About to listen to HTTP: {}", settings.port);
listenHTTP(settings, router);
Expand Down

0 comments on commit afc4cf5

Please sign in to comment.