fix: cleanupStuckedContainers

This commit is contained in:
Andras Bacsai 2023-01-23 10:37:14 +01:00
parent 18ed2527e8
commit ade7c8566d
415 changed files with 9686 additions and 6 deletions

View File

@ -172,9 +172,9 @@ const host = '0.0.0.0';
}, 60000 * 15);
// Cleanup stucked containers (not defined in Coolify, but still running and managed by Coolify)
// setInterval(async () => {
// await cleanupStuckedContainers();
// }, 60000 * 5);
setInterval(async () => {
await cleanupStuckedContainers();
}, 2000);
// checkProxies, checkFluentBit & refresh templates
setInterval(async () => {
@ -344,9 +344,16 @@ async function cleanupStuckedContainers() {
const containersArray = containers.trim().split('\n');
if (containersArray.length > 0) {
for (const container of containersArray) {
const application = await prisma.application.findFirst({ where: { id: container } });
const service = await prisma.service.findFirst({ where: { id: container } });
const database = await prisma.database.findFirst({ where: { id: container } });
const containerId = container.split('-')[0];
const application = await prisma.application.findFirst({
where: { id: { startsWith: containerId } }
});
const service = await prisma.service.findFirst({
where: { id: { startsWith: containerId } }
});
const database = await prisma.database.findFirst({
where: { id: { startsWith: containerId } }
});
if (!application && !service && !database) {
await executeCommand({ command: `docker container rm -f ${container}` });
}

View File

Before

Width:  |  Height:  |  Size: 261 B

After

Width:  |  Height:  |  Size: 261 B

View File

Before

Width:  |  Height:  |  Size: 486 B

After

Width:  |  Height:  |  Size: 486 B

View File

Before

Width:  |  Height:  |  Size: 262 B

After

Width:  |  Height:  |  Size: 262 B

Some files were not shown because too many files have changed in this diff Show More