Update bot registry when bot status in db is running
This commit is contained in:
@@ -50,19 +50,27 @@ public class BotReminderInitializerGrain : Grain, IBotReminderInitializerGrain,
|
||||
|
||||
_logger.LogInformation("Found {Count} running bots to reactivate", runningBots.Count());
|
||||
|
||||
var botRegistry = GrainFactory.GetGrain<ILiveBotRegistryGrain>(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<ILiveTradingBotGrain>(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);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user