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:
parent
b1758fb2bb
commit
c8a2a539e8
Agent/Phantom.Agent.Rpc
@ -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() {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user