Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: high cpu usage

Andras Bacsaic53f0dbb30c3
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index 5492331e6e..3f4876c945 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -107,11 +107,11 @@ fastify.listen({ port, host }, async (err: any, address: any) => {
await scheduler.start('cleanupPrismaEngines');
await scheduler.start('checkProxies');
- // setInterval(async () => {
- // if (!scheduler.workers.has('deployApplication')) {
- // scheduler.run('deployApplication');
- // }
- // }, 2000)
+ setInterval(async () => {
+ if (!scheduler.workers.has('deployApplication')) {
+ scheduler.run('deployApplication');
+ }
+ }, 2000)
// Check for update & if no build is running
setInterval(async () => {
diff --git a/apps/api/src/jobs/checkProxies.ts b/apps/api/src/jobs/checkProxies.ts
index 992281c3a0..b493d7b831 100644
--- a/apps/api/src/jobs/checkProxies.ts
+++ b/apps/api/src/jobs/checkProxies.ts
@@ -5,6 +5,8 @@ import { checkContainer } from '../lib/docker';
(async () => {
if (parentPort) {
try {
+ const { default: isReachable } = await import('is-port-reachable');
+ let portReachable;
const { arch } = await listSettings();
// Coolify Proxy local
const engine = '/var/run/docker.sock';
@@ -20,7 +22,11 @@ import { checkContainer } from '../lib/docker';
command: `docker stop -t 0 coolify-haproxy && docker rm coolify-haproxy`
})
}
- await startTraefikProxy(localDocker.id);
+ portReachable = await isReachable(80, { host: 'localhost' })
+ console.log({ port: 80, portReachable })
+ if (!portReachable) {
+ await startTraefikProxy(localDocker.id);
+ }
}
// TCP Proxies
@@ -42,7 +48,11 @@ import { checkContainer } from '../lib/docker';
command: `docker stop -t 0 haproxy-for-${publicPort} && docker rm haproxy-for-${publicPort}`
})
}
- await startTraefikTCPProxy(destinationDocker, id, publicPort, privatePort);
+ portReachable = await isReachable(publicPort, { host: destinationDocker.remoteIpAddress || 'localhost' })
+ console.log({ publicPort, portReachable })
+ if (!portReachable) {
+ await startTraefikTCPProxy(destinationDocker, id, publicPort, privatePort);
+ }
}
}
const wordpressWithFtp = await prisma.wordpress.findMany({
@@ -61,7 +71,11 @@ import { checkContainer } from '../lib/docker';
command: `docker stop -t 0 haproxy -for-${ftpPublicPort} && docker rm haproxy-for-${ftpPublicPort}`
})
}
- await startTraefikTCPProxy(destinationDocker, id, ftpPublicPort, 22, 'wordpressftp');
+ portReachable = await isReachable(ftpPublicPort, { host: destinationDocker.remoteIpAddress || 'localhost' })
+ console.log({ ftpPublicPort, portReachable })
+ if (!portReachable) {
+ await startTraefikTCPProxy(destinationDocker, id, ftpPublicPort, 22, 'wordpressftp');
+ }
}
}
@@ -82,7 +96,11 @@ import { checkContainer } from '../lib/docker';
command: `docker stop -t 0 ${id}-${publicPort} && docker rm ${id}-${publicPort} `
})
}
- await startTraefikTCPProxy(destinationDocker, id, publicPort, 9000);
+ portReachable = await isReachable(publicPort, { host: destinationDocker.remoteIpAddress || 'localhost' })
+ console.log({ publicPort, portReachable })
+ if (!portReachable) {
+ await startTraefikTCPProxy(destinationDocker, id, publicPort, 9000);
+ }
}
}