From d4798a3b2270bcde01559802e08f0ace37463d86 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 24 May 2023 20:34:40 +0200 Subject: [PATCH] fix: more aggressive cleanup --- apps/api/src/index.ts | 93 +++++++++++++++++++------------------- apps/api/src/lib/common.ts | 2 +- package.json | 4 +- 3 files changed, 50 insertions(+), 49 deletions(-) diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 18d2e6fc4..e0f57be5d 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -604,53 +604,54 @@ async function cleanupStorage() { if (!destination.remoteVerified) continue; enginesDone.add(destination.remoteIpAddress); } - let lowDiskSpace = false; - try { - let stdout = null; - if (!isDev) { - const output = await executeCommand({ - dockerId: destination.id, - command: `CONTAINER=$(docker ps -lq | head -1) && docker exec $CONTAINER sh -c 'df -kPT /'`, - shell: true - }); - stdout = output.stdout; - } else { - const output = await executeCommand({ - command: `df -kPT /` - }); - stdout = output.stdout; - } - let lines = stdout.trim().split('\n'); - let header = lines[0]; - let regex = - /^Filesystem\s+|Type\s+|1024-blocks|\s+Used|\s+Available|\s+Capacity|\s+Mounted on\s*$/g; - const boundaries = []; - let match; + await cleanupDockerStorage(destination.id); + // let lowDiskSpace = false; + // try { + // let stdout = null; + // if (!isDev) { + // const output = await executeCommand({ + // dockerId: destination.id, + // command: `CONTAINER=$(docker ps -lq | head -1) && docker exec $CONTAINER sh -c 'df -kPT /'`, + // shell: true + // }); + // stdout = output.stdout; + // } else { + // const output = await executeCommand({ + // command: `df -kPT /` + // }); + // stdout = output.stdout; + // } + // let lines = stdout.trim().split('\n'); + // let header = lines[0]; + // let regex = + // /^Filesystem\s+|Type\s+|1024-blocks|\s+Used|\s+Available|\s+Capacity|\s+Mounted on\s*$/g; + // const boundaries = []; + // let match; - while ((match = regex.exec(header))) { - boundaries.push(match[0].length); - } + // while ((match = regex.exec(header))) { + // boundaries.push(match[0].length); + // } - boundaries[boundaries.length - 1] = -1; - const data = lines.slice(1).map((line) => { - const cl = boundaries.map((boundary) => { - const column = boundary > 0 ? line.slice(0, boundary) : line; - line = line.slice(boundary); - return column.trim(); - }); - return { - capacity: Number.parseInt(cl[5], 10) / 100 - }; - }); - if (data.length > 0) { - const { capacity } = data[0]; - if (capacity > 0.8) { - lowDiskSpace = true; - } - } - } catch (error) {} - if (lowDiskSpace) { - await cleanupDockerStorage(destination.id); - } + // boundaries[boundaries.length - 1] = -1; + // const data = lines.slice(1).map((line) => { + // const cl = boundaries.map((boundary) => { + // const column = boundary > 0 ? line.slice(0, boundary) : line; + // line = line.slice(boundary); + // return column.trim(); + // }); + // return { + // capacity: Number.parseInt(cl[5], 10) / 100 + // }; + // }); + // if (data.length > 0) { + // const { capacity } = data[0]; + // if (capacity > 0.8) { + // lowDiskSpace = true; + // } + // } + // } catch (error) {} + // if (lowDiskSpace) { + // await cleanupDockerStorage(destination.id); + // } } } diff --git a/apps/api/src/lib/common.ts b/apps/api/src/lib/common.ts index dd17f1c05..a781bc0cb 100644 --- a/apps/api/src/lib/common.ts +++ b/apps/api/src/lib/common.ts @@ -19,7 +19,7 @@ import { saveBuildLog } from './buildPacks/common'; import { scheduler } from './scheduler'; import type { ExecaChildProcess } from 'execa'; -export const version = '3.12.31'; +export const version = '3.12.32'; export const isDev = process.env.NODE_ENV === 'development'; export const proxyPort = process.env.COOLIFY_PROXY_PORT; export const proxySecurePort = process.env.COOLIFY_PROXY_SECURE_PORT; diff --git a/package.json b/package.json index c4ce72c9d..691c42a48 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "coolify", "description": "An open-source & self-hostable Heroku / Netlify alternative.", - "version": "3.12.31", + "version": "3.12.32", "license": "Apache-2.0", "repository": "github:coollabsio/coolify", "scripts": { @@ -50,4 +50,4 @@ "open-source", "coolify" ] -} +} \ No newline at end of file