This commit is contained in:
Andras Bacsai 2022-08-26 09:01:48 +02:00
parent ee4360de3a
commit 224604f2e7
5 changed files with 16 additions and 31 deletions

View File

@ -21,7 +21,7 @@ ENV PRISMA_QUERY_ENGINE_BINARY=/app/prisma-engines/query-engine \
PRISMA_CLI_QUERY_ENGINE_TYPE=binary \ PRISMA_CLI_QUERY_ENGINE_TYPE=binary \
PRISMA_CLIENT_ENGINE_TYPE=binary PRISMA_CLIENT_ENGINE_TYPE=binary
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 /app/prisma-engines/
RUN apk add --no-cache git git-lfs openssh-client curl jq cmake sqlite openssl psmisc 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

View File

@ -103,8 +103,7 @@ fastify.listen({ port, host }, async (err: any, address: any) => {
} }
console.log(`Coolify's API is listening on ${host}:${port}`); console.log(`Coolify's API is listening on ${host}:${port}`);
await initServer(); await initServer();
// await scheduler.start('cleanupPrismaEngines');
// await scheduler.start('checkProxies');
const graceful = new Graceful({ brees: [scheduler] }); const graceful = new Graceful({ brees: [scheduler] });
graceful.listen(); graceful.listen();
@ -133,9 +132,9 @@ fastify.listen({ port, host }, async (err: any, address: any) => {
}, 10000) }, 10000)
// cleanupPrismaEngines // cleanupPrismaEngines
setInterval(async () => { // setInterval(async () => {
scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:cleanupPrismaEngines") // scheduler.workers.has('infrastructure') && scheduler.workers.get('infrastructure').postMessage("action:cleanupPrismaEngines")
}, 60000) // }, 60000)
await getArch(); await getArch();
await getIPAddress(); await getIPAddress();

View File

@ -39,7 +39,7 @@ async function autoUpdater() {
console.log(error); console.log(error);
} }
} }
async function checkProxies(){ async function checkProxies() {
try { try {
const { default: isReachable } = await import('is-port-reachable'); const { default: isReachable } = await import('is-port-reachable');
let portReachable; let portReachable;
@ -50,7 +50,7 @@ async function checkProxies(){
const localDocker = await prisma.destinationDocker.findFirst({ const localDocker = await prisma.destinationDocker.findFirst({
where: { engine, network: 'coolify' } where: { engine, network: 'coolify' }
}); });
if (localDocker && localDocker.isCoolifyProxyUsed) { if (localDocker && localDocker.isCoolifyProxyUsed) {
portReachable = await isReachable(80, { host: ipv4 || ipv6 }) portReachable = await isReachable(80, { host: ipv4 || ipv6 })
console.log({ port: 80, portReachable }); console.log({ port: 80, portReachable });
if (!portReachable) { if (!portReachable) {
@ -106,16 +106,16 @@ async function checkProxies(){
} }
} }
} }
} catch(error) { } catch (error) {
} }
} }
async function cleanupPrismaEngines(){ async function cleanupPrismaEngines() {
if (!isDev) { if (!isDev) {
try { try {
const { stdout } = await asyncExecShell(`ps -ef | grep /app/prisma-engines/query-engine | grep -v grep | wc -l | xargs`) const { stdout } = await asyncExecShell(`ps -ef | grep /app/prisma-engines/query-engine | grep -v grep | wc -l | xargs`)
if (stdout.trim() != null && stdout.trim() != '' && Number(stdout.trim()) > 1) { if (stdout.trim() != null && stdout.trim() != '' && Number(stdout.trim()) > 1) {
await asyncExecShell(`killall -q -e /app/prisma-engines/query-engine -o 10m`) await asyncExecShell(`killall -q -e /app/prisma-engines/query-engine -o 1m`)
} }
} catch (error) { } catch (error) {
console.log(error); console.log(error);
@ -178,7 +178,7 @@ async function cleanupStorage() {
} }
(async () => { (async () => {
let status ={ let status = {
cleanupStorage: false, cleanupStorage: false,
autoUpdater: false autoUpdater: false
} }

View File

@ -155,11 +155,11 @@ export const prisma = new PrismaClient({
], ],
}); });
// prisma.$on('query', (e) => { prisma.$on('query', (e) => {
// console.log('Query: ' + e.query) console.log('Query: ' + e.query)
// console.log('Params: ' + e.params) console.log('Params: ' + e.params)
// console.log('Duration: ' + e.duration + 'ms') console.log('Duration: ' + e.duration + 'ms')
// }) })
export const base64Encode = (text: string): string => { export const base64Encode = (text: string): string => {
return Buffer.from(text).toString('base64'); return Buffer.from(text).toString('base64');
}; };

View File

@ -20,20 +20,6 @@ const options: any = {
jobs: [ jobs: [
{ name: 'infrastructure' }, { name: 'infrastructure' },
{ name: 'deployApplication' }, { name: 'deployApplication' },
// {
// name: 'cleanupStorage',
// },
// {
// name: 'cleanupPrismaEngines',
// interval: '1m'
// },
// {
// name: 'checkProxies',
// interval: '10s'
// },
// {
// name: 'autoUpdater',
// }
], ],
}; };
if (isDev) options.root = path.join(__dirname, '../jobs'); if (isDev) options.root = path.join(__dirname, '../jobs');