Skip to content

Commit

Permalink
Also stop tcp listeners on signal shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
hewison-chris committed Mar 17, 2022
1 parent 33e7d88 commit 9769523
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions source/agora/node/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ private SigHandlerT getSignalHandler () @safe pure nothrow @nogc
{
try
{
printf("shutting down HTTP listener.\n");
l.stopListening();
l = typeof(l).init;
}
Expand All @@ -240,6 +241,25 @@ private SigHandlerT getSignalHandler () @safe pure nothrow @nogc
}
}
}
foreach (ref l; listeners.tcp)
{
try
{
printf("shutting down TCP listener.\n");
l.stopListening();
l = typeof(l).init;
}
catch (Exception exc)
{
printf("Exception thrown while stopping a TCP listener: %.*s\n",
cast(int) exc.msg.length, exc.msg.ptr);
debug {
scope (failure) assert(0);
writeln("========================================");
writeln("Full stack trace: ", exc);
}
}
}

printf("Calling node shutdown procedure...\n");
if (listeners.node !is null)
Expand Down

0 comments on commit 9769523

Please sign in to comment.