Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: clear queue on cancelling jobs

Andras Bacsaic8ae72893ab6
diff --git a/apps/api/src/jobs/deployApplication.ts b/apps/api/src/jobs/deployApplication.ts
index 9259e39764..19899d9008 100644
--- a/apps/api/src/jobs/deployApplication.ts
+++ b/apps/api/src/jobs/deployApplication.ts
@@ -28,6 +28,10 @@ import * as buildpacks from '../lib/buildPacks';
parentPort.postMessage({ size: queue.size, pending: queue.pending, caller: 'cleanupStorage' });
return;
}
+ if (message === 'action:flushQueue') {
+ queue.clear()
+ return;
+ }
await queue.add(async () => {
const {
diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts
index 1a78a47afc..379f79a34b 100644
--- a/apps/api/src/lib/common.ts
+++ b/apps/api/src/lib/common.ts
@@ -17,8 +17,9 @@ import { checkContainer, removeContainer } from './docker';
import { day } from './dayjs';
import * as serviceFields from './serviceFields'
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';
const algorithm = 'aes-256-ctr';
@@ -1879,6 +1880,10 @@ export async function stopBuild(buildId, applicationId) {
}
if (count > 50) {
clearInterval(interval);
+ if (scheduler.workers.has('deployApplication')) {
+ scheduler.workers.get('deployApplication').postMessage("action:flushQueue")
+ }
+ await cleanupDB(buildId);
return reject(new Error('Build canceled'));
}
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;
if (!containerObj.Names.startsWith(`${applicationId} `)) {
await removeContainer({ id, dockerId });
+
clearInterval(interval);
return resolve();
}
}
}
count++;
- } catch (error) { } finally {
- await cleanupDB(buildId);
- }
+ } catch (error) { }
}, 100);
});
}
@@ -1914,10 +1918,7 @@ export function convertTolOldVolumeNames(type) {
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) {
// Cleanup old coolify images
try {
diff --git a/apps/api/src/lib/scheduler.ts b/apps/api/src/lib/scheduler.ts
index b120dcea13..5d8a578448 100644
--- a/apps/api/src/lib/scheduler.ts
+++ b/apps/api/src/lib/scheduler.ts
@@ -2,7 +2,8 @@ import Bree from 'bree';
import path from 'path';
import Cabin from 'cabin';
import TSBree from '@breejs/ts-worker';
-import { isDev } from './common';
+
+export const isDev = process.env.NODE_ENV === 'development';
Bree.extend(TSBree);
diff --git a/package.json b/package.json
index 99cd0a1e65..9d6fd9250e 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "coolify",
"description": "An open-source & self-hostable Heroku / Netlify alternative.",
- "version": "3.8.0",
+ "version": "3.8.1",
"license": "Apache-2.0",
"repository": "github:coollabsio/coolify",
"scripts": {