Made shut down stale tasks configurable.

Signed-off-by: Bogdan Nechyporenko <bnechyporenko@bol.com>
This commit is contained in:
Bogdan Nechyporenko
2023-10-14 23:14:36 +02:00
committed by Fredrik Adelöw
parent de7513e7fa
commit ca3f355851
@@ -110,18 +110,18 @@ export const scaffolderPlugin = createBackendPlugin({
const databaseTaskStore = await DatabaseTaskStore.create({
database,
});
const { tasks: pendingTasks } = await databaseTaskStore.list({
const { tasks: processingTasks } = await databaseTaskStore.list({
status: 'processing',
});
if (pendingTasks.length > 0) {
if (processingTasks.length > 0) {
await Promise.all(
pendingTasks.map(task =>
processingTasks.map(task =>
databaseTaskStore.shutdownTask({ taskId: task.id }),
),
);
logger.info(
`Successfully shut ${pendingTasks.length} processing tasks down.`,
`Successfully shut ${processingTasks.length} processing tasks down.`,
);
}
});