Skip to content

Commit 3421de0

Browse files
authored
Merge pull request coollabsio#558 from coollabsio/next
v3.8.1
2 parents 31fdbdf + e44eb01 commit 3421de0

File tree

8 files changed

+34
-19
lines changed

8 files changed

+34
-19
lines changed

apps/api/src/jobs/deployApplication.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ import * as buildpacks from '../lib/buildPacks';
2828
parentPort.postMessage({ size: queue.size, pending: queue.pending, caller: 'cleanupStorage' });
2929
return;
3030
}
31+
if (message === 'action:flushQueue') {
32+
queue.clear()
33+
return;
34+
}
3135

3236
await queue.add(async () => {
3337
const {
@@ -330,8 +334,8 @@ import * as buildpacks from '../lib/buildPacks';
330334
await saveBuildLog({ line: 'Deployment successful!', buildId, applicationId });
331335
} catch (error) {
332336
await saveBuildLog({ line: error, buildId, applicationId });
333-
await prisma.build.update({
334-
where: { id: message.build_id },
337+
await prisma.build.updateMany({
338+
where: { id: message.build_id, status: { in: ['queued', 'running'] } },
335339
data: { status: 'failed' }
336340
});
337341
throw new Error(error);
@@ -346,8 +350,8 @@ import * as buildpacks from '../lib/buildPacks';
346350

347351
}
348352
catch (error) {
349-
await prisma.build.update({
350-
where: { id: message.build_id },
353+
await prisma.build.updateMany({
354+
where: { id: message.build_id, status: { in: ['queued', 'running'] } },
351355
data: { status: 'failed' }
352356
});
353357
await saveBuildLog({ line: error, buildId, applicationId });

apps/api/src/lib/buildPacks/common.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,10 @@ export async function buildImage({
551551
const dockerFile = isCache ? `${dockerFileLocation}-cache` : `${dockerFileLocation}`
552552
const cache = `${applicationId}:${tag}${isCache ? '-cache' : ''}`
553553
await executeDockerCmd({ debug, buildId, applicationId, dockerId, command: `docker build --progress plain -f ${workdir}/${dockerFile} -t ${cache} ${workdir}` })
554+
const { status } = await prisma.build.findUnique({ where: { id: buildId } })
555+
if (status === 'canceled') {
556+
throw new Error('Build canceled.')
557+
}
554558
if (isCache) {
555559
await saveBuildLog({ line: `Building cache image successful.`, buildId, applicationId });
556560
} else {

apps/api/src/lib/common.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import { checkContainer, removeContainer } from './docker';
1717
import { day } from './dayjs';
1818
import * as serviceFields from './serviceFields'
1919
import { saveBuildLog } from './buildPacks/common';
20+
import { scheduler } from './scheduler';
2021

21-
export const version = '3.8.0';
22+
export const version = '3.8.1';
2223
export const isDev = process.env.NODE_ENV === 'development';
2324

2425
const algorithm = 'aes-256-ctr';
@@ -1873,12 +1874,16 @@ export async function stopBuild(buildId, applicationId) {
18731874
const { engine, id: dockerId } = await prisma.destinationDocker.findFirst({ where: { id: destinationDockerId } });
18741875
const interval = setInterval(async () => {
18751876
try {
1876-
if (status === 'failed') {
1877+
if (status === 'failed' || status === 'canceled') {
18771878
clearInterval(interval);
18781879
return resolve();
18791880
}
1880-
if (count > 50) {
1881+
if (count > 15) {
18811882
clearInterval(interval);
1883+
if (scheduler.workers.has('deployApplication')) {
1884+
scheduler.workers.get('deployApplication').postMessage("action:flushQueue")
1885+
}
1886+
await cleanupDB(buildId);
18821887
return reject(new Error('Build canceled'));
18831888
}
18841889
const { stdout: buildContainers } = await executeDockerCmd({ dockerId, command: `docker container ls --filter "label=coolify.buildId=${buildId}" --format '{{json .}}'` })
@@ -1890,22 +1895,24 @@ export async function stopBuild(buildId, applicationId) {
18901895
if (!containerObj.Names.startsWith(`${applicationId} `)) {
18911896
await removeContainer({ id, dockerId });
18921897
clearInterval(interval);
1898+
if (scheduler.workers.has('deployApplication')) {
1899+
scheduler.workers.get('deployApplication').postMessage("action:flushQueue")
1900+
}
1901+
await cleanupDB(buildId);
18931902
return resolve();
18941903
}
18951904
}
18961905
}
18971906
count++;
1898-
} catch (error) { } finally {
1899-
await cleanupDB(buildId);
1900-
}
1907+
} catch (error) { }
19011908
}, 100);
19021909
});
19031910
}
19041911

19051912
async function cleanupDB(buildId: string) {
19061913
const data = await prisma.build.findUnique({ where: { id: buildId } });
19071914
if (data?.status === 'queued' || data?.status === 'running') {
1908-
await prisma.build.update({ where: { id: buildId }, data: { status: 'failed' } });
1915+
await prisma.build.update({ where: { id: buildId }, data: { status: 'canceled' } });
19091916
}
19101917
}
19111918

@@ -1914,10 +1921,7 @@ export function convertTolOldVolumeNames(type) {
19141921
return 'nc'
19151922
}
19161923
}
1917-
// export async function getAvailableServices(): Promise<any> {
1918-
// const { data } = await axios.get(`https://gist.githubusercontent.com/andrasbacsai/4aac36d8d6214dbfc34fa78110554a50/raw/5b27e6c37d78aaeedc1148d797112c827a2f43cf/availableServices.json`)
1919-
// return data
1920-
//
1924+
19211925
export async function cleanupDockerStorage(dockerId, lowDiskSpace, force) {
19221926
// Cleanup old coolify images
19231927
try {

apps/api/src/lib/scheduler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import Bree from 'bree';
22
import path from 'path';
33
import Cabin from 'cabin';
44
import TSBree from '@breejs/ts-worker';
5-
import { isDev } from './common';
5+
6+
export const isDev = process.env.NODE_ENV === 'development';
67

78
Bree.extend(TSBree);
89

apps/ui/src/routes/applications/[id]/logs/build.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
class="tooltip tooltip-primary tooltip-top flex cursor-pointer items-center justify-center border-l-2 py-4 no-underline transition-all duration-100 hover:bg-coolgray-400 hover:shadow-xl"
147147
class:bg-coolgray-400={buildId === build.id}
148148
class:border-red-500={build.status === 'failed'}
149+
class:border-orange-500={build.status === 'canceled'}
149150
class:border-green-500={build.status === 'success'}
150151
class:border-yellow-500={build.status === 'running'}
151152
>

apps/ui/src/routes/applications/[id]/previews.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,13 @@
194194
</div>
195195
</a>
196196
<div class="flex items-center justify-center">
197-
<button class="bg-coollabs hover:bg-coollabs-100" on:click={() => redeploy(container)}
197+
<button class="btn btn-sm bg-coollabs hover:bg-coollabs-100" on:click={() => redeploy(container)}
198198
>{$t('application.preview.redeploy')}</button
199199
>
200200
</div>
201201
<div class="flex items-center justify-center">
202202
<button
203+
class="btn btn-sm"
203204
class:bg-red-600={!loading.removing}
204205
class:hover:bg-red-500={!loading.removing}
205206
disabled={loading.removing}

apps/ui/src/routes/index.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@
343343
</table>
344344
</div>
345345
</div>
346-
{:else}
346+
{:else if $appSession.teamId !== '0'}
347347
<div class="text-center text-xl font-bold">Nothing is configured yet.</div>
348348
{/if}
349349
{#if $appSession.teamId === '0'}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "coolify",
33
"description": "An open-source & self-hostable Heroku / Netlify alternative.",
4-
"version": "3.8.0",
4+
"version": "3.8.1",
55
"license": "Apache-2.0",
66
"repository": "github:coollabsio/coolify",
77
"scripts": {

0 commit comments

Comments
 (0)