Fix stop/restart

This commit is contained in:
2025-07-10 12:53:59 +07:00
parent 0c1184a22d
commit 14b3a3c39a
9 changed files with 164 additions and 271 deletions

View File

@@ -174,7 +174,18 @@ namespace Managing.Application.ManageBot
bot.User = user;
// Config is already set correctly from backup data, so we only need to restore signals, positions, etc.
bot.LoadBackup(backupBot);
bot.Start();
// Only start the bot if the backup status is Up
if (backupBot.LastStatus == BotStatus.Up)
{
// Start the bot asynchronously without waiting for completion
_ = Task.Run(() => bot.Start());
}
else
{
// Keep the bot in Down status if it was originally Down
bot.Stop();
}
}
public IBot CreateSimpleBot(string botName, Workflow workflow)
@@ -246,12 +257,15 @@ namespace Managing.Application.ManageBot
{
// Stop the bot first to ensure clean state
bot.Stop();
// Small delay to ensure stop is complete
await Task.Delay(100);
// Restart the bot (this will update StartupTime)
bot.Restart();
// Start the bot asynchronously without waiting for completion
_ = Task.Run(() => bot.Start());
var restartMessage = $"🔄 **Bot Restarted**\n\n" +
$"🎯 **Agent:** {bot.User.AgentName}\n" +