From 717ed57c0cb3cd089b8105e3f87bcf14670d5336 Mon Sep 17 00:00:00 2001 From: bludnic Date: Sun, 22 Dec 2024 04:59:00 +0000 Subject: [PATCH] fix(platform): doesn't cancel orders on clean up --- packages/bot/src/platform.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/bot/src/platform.ts b/packages/bot/src/platform.ts index c249d3bb..1b776044 100644 --- a/packages/bot/src/platform.ts +++ b/packages/bot/src/platform.ts @@ -58,7 +58,7 @@ export class Platform { if (bots.length === 0) return; logger.info(`[Processor] Stopping ${bots.length} bots gracefully…`); - for (const bot of bots) { + for (let bot of bots) { // Check if the strategy function exists // If not, just mark the bot as disabled try { @@ -78,14 +78,15 @@ export class Platform { continue; } - const botProcessor = new BotProcessing(bot); - await botProcessor.processStopCommand(); - - await xprisma.bot.custom.update({ + bot = await xprisma.bot.custom.update({ where: { id: bot.id }, data: { enabled: false, processing: false }, + include: { exchangeAccount: true }, }); + const botProcessor = new BotProcessing(bot); + await botProcessor.processStopCommand(); + logger.info(`[Processor] Bot stopped [id=${bot.id} name=${bot.name}]`); } }