From fc09e4c10e6a3427dd3a5cd0017fb840c34780e2 Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Mon, 1 Mar 2021 13:19:29 +0100 Subject: [PATCH] :bug: Fix issue that manual executionscould not be stopped when running with queue (#1484) --- packages/cli/src/Server.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 4b4e376a83..bf4a4e6da2 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -1713,6 +1713,20 @@ class App { // Forces the execution to stop this.app.post(`/${this.restEndpoint}/executions-current/:id/stop`, ResponseHelper.send(async (req: express.Request, res: express.Response): Promise => { if (config.get('executions.mode') === 'queue') { + // Manual executions should still be stoppable, so + // try notifying the `activeExecutions` to stop it. + const result = await this.activeExecutionsInstance.stopExecution(req.params.id); + if (result !== undefined) { + const returnData: IExecutionsStopData = { + mode: result.mode, + startedAt: new Date(result.startedAt), + stoppedAt: result.stoppedAt ? new Date(result.stoppedAt) : undefined, + finished: result.finished, + }; + + return returnData; + } + const currentJobs = await Queue.getInstance().getJobs(['active', 'waiting']); const job = currentJobs.find(job => job.data.executionId.toString() === req.params.id);