Implemented installation handling. Added crash handling. Refactored tasks reset/cancel functions

This commit is contained in:
2025-02-14 21:15:03 +01:00
parent 761ab455f0
commit 1fbf1ae9ec
12 changed files with 264 additions and 44 deletions

View File

@@ -115,15 +115,27 @@ public class ServerService : IHostedLifecycleService
Server? server;
lock (Servers)
server = Servers.FirstOrDefault(x => x.RuntimeContainerId == message.ID || x.InstallationContainerId == message.ID);
// TODO: Maybe implement a lookup for containers which id isn't set in the cache
if (server == null)
return;
// Check if it's a runtime container
lock (Servers)
server = Servers.FirstOrDefault(x => x.RuntimeContainerId == message.ID);
await server.NotifyContainerDied();
if (server != null)
{
await server.NotifyRuntimeContainerDied();
return;
}
// Check if it's an installation container
lock (Servers)
server = Servers.FirstOrDefault(x => x.InstallationContainerId == message.ID);
if (server != null)
{
await server.NotifyInstallationContainerDied();
return;
}
}), Cancellation.Token);
}
catch (TaskCanceledException)
@@ -210,10 +222,10 @@ public class ServerService : IHostedLifecycleService
}
public Task StartingAsync(CancellationToken cancellationToken)
=> Task.CompletedTask;
=> Task.CompletedTask;
public Task StoppedAsync(CancellationToken cancellationToken)
=> Task.CompletedTask;
=> Task.CompletedTask;
public async Task StoppingAsync(CancellationToken cancellationToken)
{