fix: clear queue on cancelling jobs

This commit is contained in:
Andras Bacsai
2022-08-24 09:39:24 +02:00
parent cbc3735ca0
commit c8ae72893a
4 changed files with 16 additions and 10 deletions

View File

@@ -28,6 +28,10 @@ import * as buildpacks from '../lib/buildPacks';
parentPort.postMessage({ size: queue.size, pending: queue.pending, caller: 'cleanupStorage' }); parentPort.postMessage({ size: queue.size, pending: queue.pending, caller: 'cleanupStorage' });
return; return;
} }
if (message === 'action:flushQueue') {
queue.clear()
return;
}
await queue.add(async () => { await queue.add(async () => {
const { const {

View File

@@ -17,8 +17,9 @@ import { checkContainer, removeContainer } from './docker';
import { day } from './dayjs'; import { day } from './dayjs';
import * as serviceFields from './serviceFields' import * as serviceFields from './serviceFields'
import { saveBuildLog } from './buildPacks/common'; import { saveBuildLog } from './buildPacks/common';
import { scheduler } from './scheduler';
export const version = '3.8.0'; export const version = '3.8.1';
export const isDev = process.env.NODE_ENV === 'development'; export const isDev = process.env.NODE_ENV === 'development';
const algorithm = 'aes-256-ctr'; const algorithm = 'aes-256-ctr';
@@ -1879,6 +1880,10 @@ export async function stopBuild(buildId, applicationId) {
} }
if (count > 50) { if (count > 50) {
clearInterval(interval); clearInterval(interval);
if (scheduler.workers.has('deployApplication')) {
scheduler.workers.get('deployApplication').postMessage("action:flushQueue")
}
await cleanupDB(buildId);
return reject(new Error('Build canceled')); return reject(new Error('Build canceled'));
} }
const { stdout: buildContainers } = await executeDockerCmd({ dockerId, command: `docker container ls --filter "label=coolify.buildId=${buildId}" --format '{{json .}}'` }) const { stdout: buildContainers } = await executeDockerCmd({ dockerId, command: `docker container ls --filter "label=coolify.buildId=${buildId}" --format '{{json .}}'` })
@@ -1889,15 +1894,14 @@ export async function stopBuild(buildId, applicationId) {
const id = containerObj.ID; const id = containerObj.ID;
if (!containerObj.Names.startsWith(`${applicationId} `)) { if (!containerObj.Names.startsWith(`${applicationId} `)) {
await removeContainer({ id, dockerId }); await removeContainer({ id, dockerId });
clearInterval(interval); clearInterval(interval);
return resolve(); return resolve();
} }
} }
} }
count++; count++;
} catch (error) { } finally { } catch (error) { }
await cleanupDB(buildId);
}
}, 100); }, 100);
}); });
} }
@@ -1914,10 +1918,7 @@ export function convertTolOldVolumeNames(type) {
return 'nc' return 'nc'
} }
} }
// export async function getAvailableServices(): Promise<any> {
// const { data } = await axios.get(`https://gist.githubusercontent.com/andrasbacsai/4aac36d8d6214dbfc34fa78110554a50/raw/5b27e6c37d78aaeedc1148d797112c827a2f43cf/availableServices.json`)
// return data
//
export async function cleanupDockerStorage(dockerId, lowDiskSpace, force) { export async function cleanupDockerStorage(dockerId, lowDiskSpace, force) {
// Cleanup old coolify images // Cleanup old coolify images
try { try {

View File

@@ -2,7 +2,8 @@ import Bree from 'bree';
import path from 'path'; import path from 'path';
import Cabin from 'cabin'; import Cabin from 'cabin';
import TSBree from '@breejs/ts-worker'; import TSBree from '@breejs/ts-worker';
import { isDev } from './common';
export const isDev = process.env.NODE_ENV === 'development';
Bree.extend(TSBree); Bree.extend(TSBree);

View File

@@ -1,7 +1,7 @@
{ {
"name": "coolify", "name": "coolify",
"description": "An open-source & self-hostable Heroku / Netlify alternative.", "description": "An open-source & self-hostable Heroku / Netlify alternative.",
"version": "3.8.0", "version": "3.8.1",
"license": "Apache-2.0", "license": "Apache-2.0",
"repository": "github:coollabsio/coolify", "repository": "github:coollabsio/coolify",
"scripts": { "scripts": {