🐛 Fix issue that manual executionscould not be stopped when running with queue (#1484)

This commit is contained in:
Omar Ajoue 2021-03-01 13:19:29 +01:00 committed by GitHub
parent 307860b21a
commit fc09e4c10e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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<IExecutionsStopData> => {
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);