mirror of
https://github.com/ershisan99/coolify.git
synced 2025-12-17 20:49:32 +00:00
fix: more aggressive cleanup
This commit is contained in:
@@ -604,53 +604,54 @@ async function cleanupStorage() {
|
|||||||
if (!destination.remoteVerified) continue;
|
if (!destination.remoteVerified) continue;
|
||||||
enginesDone.add(destination.remoteIpAddress);
|
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;
|
|
||||||
|
|
||||||
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);
|
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);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import { saveBuildLog } from './buildPacks/common';
|
|||||||
import { scheduler } from './scheduler';
|
import { scheduler } from './scheduler';
|
||||||
import type { ExecaChildProcess } from 'execa';
|
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 isDev = process.env.NODE_ENV === 'development';
|
||||||
export const proxyPort = process.env.COOLIFY_PROXY_PORT;
|
export const proxyPort = process.env.COOLIFY_PROXY_PORT;
|
||||||
export const proxySecurePort = process.env.COOLIFY_PROXY_SECURE_PORT;
|
export const proxySecurePort = process.env.COOLIFY_PROXY_SECURE_PORT;
|
||||||
|
|||||||
@@ -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.12.31",
|
"version": "3.12.32",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": "github:coollabsio/coolify",
|
"repository": "github:coollabsio/coolify",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user