fix: cleanup stucked prisma-engines
This commit is contained in:
@@ -23,7 +23,7 @@ ENV PRISMA_QUERY_ENGINE_BINARY=/app/prisma-engines/query-engine \
|
|||||||
|
|
||||||
COPY --from=coollabsio/prisma-engine:3.15 /prisma-engines/query-engine /prisma-engines/migration-engine /prisma-engines/introspection-engine /prisma-engines/prisma-fmt /app/prisma-engines/
|
COPY --from=coollabsio/prisma-engine:3.15 /prisma-engines/query-engine /prisma-engines/migration-engine /prisma-engines/introspection-engine /prisma-engines/prisma-fmt /app/prisma-engines/
|
||||||
|
|
||||||
RUN apk add --no-cache git git-lfs openssh-client curl jq cmake sqlite openssl
|
RUN apk add --no-cache git git-lfs openssh-client curl jq cmake sqlite openssl psmisc
|
||||||
RUN curl -sL https://unpkg.com/@pnpm/self-installer | node
|
RUN curl -sL https://unpkg.com/@pnpm/self-installer | node
|
||||||
|
|
||||||
RUN mkdir -p ~/.docker/cli-plugins/
|
RUN mkdir -p ~/.docker/cli-plugins/
|
||||||
|
@@ -104,6 +104,7 @@ fastify.listen({ port, host }, async (err: any, address: any) => {
|
|||||||
await initServer();
|
await initServer();
|
||||||
await scheduler.start('deployApplication');
|
await scheduler.start('deployApplication');
|
||||||
await scheduler.start('cleanupStorage');
|
await scheduler.start('cleanupStorage');
|
||||||
|
await scheduler.start('cleanupPrismaEngines');
|
||||||
await scheduler.start('checkProxies');
|
await scheduler.start('checkProxies');
|
||||||
|
|
||||||
// Check if no build is running
|
// Check if no build is running
|
||||||
@@ -116,14 +117,14 @@ fastify.listen({ port, host }, async (err: any, address: any) => {
|
|||||||
scheduler.workers.get('deployApplication').postMessage("status:autoUpdater");
|
scheduler.workers.get('deployApplication').postMessage("status:autoUpdater");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 60000 * 15)
|
}, isDev ? 5000 : 60000 * 15)
|
||||||
|
|
||||||
// Cleanup storage
|
// Cleanup storage
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
if (scheduler.workers.has('deployApplication')) {
|
if (scheduler.workers.has('deployApplication')) {
|
||||||
scheduler.workers.get('deployApplication').postMessage("status:cleanupStorage");
|
scheduler.workers.get('deployApplication').postMessage("status:cleanupStorage");
|
||||||
}
|
}
|
||||||
}, 60000 * 10)
|
}, isDev ? 5000 : 60000 * 10)
|
||||||
|
|
||||||
scheduler.on('worker deleted', async (name) => {
|
scheduler.on('worker deleted', async (name) => {
|
||||||
if (name === 'autoUpdater' || name === 'cleanupStorage') {
|
if (name === 'autoUpdater' || name === 'cleanupStorage') {
|
||||||
|
@@ -4,6 +4,7 @@ import { checkContainer } from '../lib/docker';
|
|||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
if (parentPort) {
|
if (parentPort) {
|
||||||
|
try {
|
||||||
// Coolify Proxy local
|
// Coolify Proxy local
|
||||||
const engine = '/var/run/docker.sock';
|
const engine = '/var/run/docker.sock';
|
||||||
const localDocker = await prisma.destinationDocker.findFirst({
|
const localDocker = await prisma.destinationDocker.findFirst({
|
||||||
@@ -19,7 +20,6 @@ import { checkContainer } from '../lib/docker';
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
await startTraefikProxy(localDocker.id);
|
await startTraefikProxy(localDocker.id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TCP Proxies
|
// TCP Proxies
|
||||||
@@ -42,7 +42,6 @@ import { checkContainer } from '../lib/docker';
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
await startTraefikTCPProxy(destinationDocker, id, publicPort, privatePort);
|
await startTraefikTCPProxy(destinationDocker, id, publicPort, privatePort);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const wordpressWithFtp = await prisma.wordpress.findMany({
|
const wordpressWithFtp = await prisma.wordpress.findMany({
|
||||||
@@ -85,6 +84,12 @@ import { checkContainer } from '../lib/docker';
|
|||||||
await startTraefikTCPProxy(destinationDocker, id, publicPort, 9000);
|
await startTraefikTCPProxy(destinationDocker, id, publicPort, 9000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
|
||||||
|
} finally {
|
||||||
await prisma.$disconnect();
|
await prisma.$disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
} else process.exit(0);
|
} else process.exit(0);
|
||||||
})();
|
})();
|
||||||
|
16
apps/api/src/jobs/cleanupPrismaEngines.ts
Normal file
16
apps/api/src/jobs/cleanupPrismaEngines.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { parentPort } from 'node:worker_threads';
|
||||||
|
import { asyncExecShell, isDev, prisma } from '../lib/common';
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
if (parentPort) {
|
||||||
|
if (!isDev) {
|
||||||
|
try {
|
||||||
|
await asyncExecShell(`killall -q -e /app/prisma-engines/query-engine -o 10m`)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
} finally {
|
||||||
|
await prisma.$disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else process.exit(0);
|
||||||
|
})();
|
@@ -35,6 +35,9 @@ const options: any = {
|
|||||||
{
|
{
|
||||||
name: 'cleanupStorage',
|
name: 'cleanupStorage',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'cleanupPrismaEngines',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'checkProxies',
|
name: 'checkProxies',
|
||||||
interval: '10s'
|
interval: '10s'
|
||||||
|
Reference in New Issue
Block a user