1
0
mirror of https://github.com/chylex/Minecraft-Phantom-Panel.git synced 2025-05-04 18:34:05 +02:00

Move Agent keep-alive loop into an unmanaged task to ensure unreachable Server does not prevent Agent shutdown

This commit is contained in:
chylex 2022-12-31 23:53:13 +01:00
parent b1758fb2bb
commit c8a2a539e8
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548
2 changed files with 3 additions and 4 deletions
Agent/Phantom.Agent.Rpc

View File

@ -1,6 +1,5 @@
using Phantom.Common.Logging;
using Phantom.Common.Messages.ToServer;
using Phantom.Utils.Runtime;
using Serilog;
namespace Phantom.Agent.Rpc;
@ -13,9 +12,9 @@ sealed class KeepAliveLoop {
private readonly RpcServerConnection connection;
private readonly CancellationTokenSource cancellationTokenSource = new ();
public KeepAliveLoop(RpcServerConnection connection, TaskManager taskManager) {
public KeepAliveLoop(RpcServerConnection connection) {
this.connection = connection;
taskManager.Run(Run);
Task.Run(Run);
}
private async Task Run() {

View File

@ -54,7 +54,7 @@ public sealed class RpcLauncher : RpcRuntime<ClientSocket> {
var logger = config.Logger;
var handler = new MessageToAgentHandler(messageListenerFactory(connection), logger, taskManager, receiveCancellationToken);
var keepAliveLoop = new KeepAliveLoop(connection, taskManager);
var keepAliveLoop = new KeepAliveLoop(connection);
try {
while (!receiveCancellationToken.IsCancellationRequested) {