Coordinator fix

This commit is contained in:
Kwoth
2022-03-21 01:52:32 +01:00
parent 86e728b753
commit 57e65e5515
2 changed files with 29 additions and 23 deletions

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -9,7 +9,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.41.0" /> <PackageReference Include="Grpc.AspNetCore" Version="2.44.0" />
<PackageReference Include="Serilog" Version="2.10.0" /> <PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" /> <PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" /> <PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />

View File

@@ -114,14 +114,6 @@ namespace NadekoBot.Coordinator
StartShard(shardId); StartShard(shardId);
break; break;
} }
if (status.Process is null or {HasExited: true})
{
Log.Warning("Shard {ShardId} is starting (process)...", shardId);
hadAction = true;
StartShard(shardId);
break;
}
if (DateTime.UtcNow - status.LastUpdate > if (DateTime.UtcNow - status.LastUpdate >
TimeSpan.FromSeconds(_config.UnresponsiveSec)) TimeSpan.FromSeconds(_config.UnresponsiveSec))
@@ -139,6 +131,24 @@ namespace NadekoBot.Coordinator
StartShard(shardId); StartShard(shardId);
break; break;
} }
try
{
if (status.Process is null or { HasExited: true })
{
Log.Warning("Shard {ShardId} is starting (process)...", shardId);
hadAction = true;
StartShard(shardId);
break;
}
}
catch (InvalidOperationException)
{
Log.Warning("Process for shard {ShardId} is bugged... ", shardId);
hadAction = true;
StartShard(shardId);
break;
}
} }
} }
@@ -161,17 +171,13 @@ namespace NadekoBot.Coordinator
var status = _shardStatuses[shardId]; var status = _shardStatuses[shardId];
try try
{ {
if (status.Process is { HasExited: false } p) status.Process?.Kill(true);
{ }
try catch
{ {
p.Kill(true); }
} try
catch {
{
}
}
status.Process?.Dispose(); status.Process?.Dispose();
} }
catch catch
@@ -282,8 +288,8 @@ namespace NadekoBot.Coordinator
var status = _shardStatuses[shardId]; var status = _shardStatuses[shardId];
if (status.Process is { } p) if (status.Process is { } p)
{ {
p.Kill(); try{p.Kill();} catch {}
p.Dispose(); try{p.Dispose();} catch {}
_shardStatuses[shardId] = status with _shardStatuses[shardId] = status with
{ {
Process = null, Process = null,