diff --git a/src/Managing.Application/Bots/Grains/BotReminderInitializerGrain.cs b/src/Managing.Application/Bots/Grains/BotReminderInitializerGrain.cs index 97a8f741..fcb8762e 100644 --- a/src/Managing.Application/Bots/Grains/BotReminderInitializerGrain.cs +++ b/src/Managing.Application/Bots/Grains/BotReminderInitializerGrain.cs @@ -50,19 +50,27 @@ public class BotReminderInitializerGrain : Grain, IBotReminderInitializerGrain, _logger.LogInformation("Found {Count} running bots to reactivate", runningBots.Count()); + var botRegistry = GrainFactory.GetGrain(0); + // Ping each running bot to reactivate it and ensure reminders are registered var tasks = runningBots.Select(async bot => { try { - _logger.LogDebug("Pinging bot {BotId} ({BotName}) to reactivate", bot.Identifier, bot.Name); + _logger.LogDebug("Reactivating bot {BotId} ({BotName})", bot.Identifier, bot.Name); + // First, update the bot status in the registry to Running + await botRegistry.UpdateBotStatus(bot.Identifier, BotStatus.Running); + + _logger.LogDebug("Updated registry status to Running for bot {BotId} ({BotName})", bot.Identifier, bot.Name); + + // Then ping the bot to reactivate it var grain = GrainFactory.GetGrain(bot.Identifier); var success = await grain.PingAsync(); if (success) { - _logger.LogDebug("Successfully pinged bot {BotId} ({BotName})", bot.Identifier, bot.Name); + _logger.LogDebug("Successfully reactivated bot {BotId} ({BotName})", bot.Identifier, bot.Name); } else { @@ -71,7 +79,7 @@ public class BotReminderInitializerGrain : Grain, IBotReminderInitializerGrain, } catch (Exception ex) { - _logger.LogError(ex, "Failed to ping bot {BotId} ({BotName})", bot.Identifier, bot.Name); + _logger.LogError(ex, "Failed to reactivate bot {BotId} ({BotName})", bot.Identifier, bot.Name); SentrySdk.CaptureException(ex); } });