mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-05 23:34:09 +02:00
refactor: Remove diagnostic logging from IrcGatewayService, Program, and ServerDirectoryService
This commit is contained in:
@@ -28,13 +28,10 @@ public sealed class ServerDirectoryService : BackgroundService
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
Console.Error.WriteLine("[DIAG] ServerDirectoryService.ExecuteAsync entered.");
|
||||
// Yield to let the host finish starting before we log or connect
|
||||
await Task.Yield();
|
||||
Console.Error.WriteLine("[DIAG] ServerDirectoryService.ExecuteAsync resumed after Task.Yield().");
|
||||
|
||||
var isPublic = _configuration.GetValue<bool>("Server:PublicServer");
|
||||
Console.Error.WriteLine($"[DIAG] ServerDirectoryService: PublicServer={isPublic}");
|
||||
if (!isPublic)
|
||||
{
|
||||
_logger.LogInformation("PublicServer is disabled — not registering with directory");
|
||||
@@ -42,7 +39,6 @@ public sealed class ServerDirectoryService : BackgroundService
|
||||
}
|
||||
|
||||
var host = _configuration["Server:PublicHost"];
|
||||
Console.Error.WriteLine($"[DIAG] ServerDirectoryService: PublicHost={host}");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(host))
|
||||
{
|
||||
@@ -63,7 +59,6 @@ public sealed class ServerDirectoryService : BackgroundService
|
||||
|
||||
try
|
||||
{
|
||||
Console.Error.WriteLine("[DIAG] ServerDirectoryService: Building new connection, entering try block.");
|
||||
var connectionPermanentlyClosed = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
connection.Reconnected += async _ =>
|
||||
@@ -85,14 +80,9 @@ public sealed class ServerDirectoryService : BackgroundService
|
||||
};
|
||||
|
||||
// Connect with retry
|
||||
Console.Error.WriteLine("[DIAG] ServerDirectoryService: Calling ConnectWithRetryAsync...");
|
||||
if (!await ConnectWithRetryAsync(connection, stoppingToken))
|
||||
{
|
||||
Console.Error.WriteLine("[DIAG] ServerDirectoryService: ConnectWithRetryAsync returned false (cancelled).");
|
||||
return;
|
||||
}
|
||||
|
||||
Console.Error.WriteLine("[DIAG] ServerDirectoryService: Connected successfully!");
|
||||
_logger.LogInformation("Successfully connected to EchoHubSpace API at {Url}", DirectoryHubUrl);
|
||||
await RegisterAsync(serverName, description, host);
|
||||
|
||||
@@ -209,25 +199,20 @@ public sealed class ServerDirectoryService : BackgroundService
|
||||
|
||||
private static async Task DisposeConnectionAsync(HubConnection connection)
|
||||
{
|
||||
Console.Error.WriteLine("[DIAG] ServerDirectoryService.DisposeConnectionAsync entered.");
|
||||
try
|
||||
{
|
||||
await connection.DisposeAsync()
|
||||
.AsTask().WaitAsync(TimeSpan.FromSeconds(3));
|
||||
Console.Error.WriteLine("[DIAG] ServerDirectoryService.DisposeConnectionAsync completed normally.");
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.Error.WriteLine("[DIAG] ServerDirectoryService.DisposeConnectionAsync timed out or failed (3s).");
|
||||
// Don't let a slow dispose block shutdown
|
||||
}
|
||||
}
|
||||
|
||||
public override async Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
Console.Error.WriteLine("[DIAG] ServerDirectoryService.StopAsync entered.");
|
||||
await base.StopAsync(cancellationToken);
|
||||
Console.Error.WriteLine("[DIAG] ServerDirectoryService.StopAsync: base.StopAsync returned.");
|
||||
_connection = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user