From 57b462223c22f0d292e5b10485fa9d142cf13e9c Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 25 Aug 2022 11:09:38 +0200 Subject: [PATCH] test --- apps/api/src/index.ts | 1 + apps/api/src/jobs/test.ts | 15 +++++++++++++++ apps/api/src/lib/scheduler.ts | 1 + 3 files changed, 17 insertions(+) create mode 100644 apps/api/src/jobs/test.ts diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 6130ebf7f..52b4bfd50 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -104,6 +104,7 @@ fastify.listen({ port, host }, async (err: any, address: any) => { } console.log(`Coolify's API is listening on ${host}:${port}`); await initServer(); + await scheduler.start('test'); // await scheduler.start('cleanupPrismaEngines'); // await scheduler.start('checkProxies'); diff --git a/apps/api/src/jobs/test.ts b/apps/api/src/jobs/test.ts new file mode 100644 index 000000000..2d0fc44c3 --- /dev/null +++ b/apps/api/src/jobs/test.ts @@ -0,0 +1,15 @@ +import { parentPort } from 'node:worker_threads';; + +(async () => { + if (parentPort) { + parentPort.on('message', async (message) => { + if (message === 'error') throw new Error('oops'); + if (message === 'cancel') { + parentPort.postMessage('cancelled'); + process.exit(0); + } + }); + console.log('test job started'); + process.exit(0) + } else process.exit(0); +})(); diff --git a/apps/api/src/lib/scheduler.ts b/apps/api/src/lib/scheduler.ts index 6c233d050..efe12d5c0 100644 --- a/apps/api/src/lib/scheduler.ts +++ b/apps/api/src/lib/scheduler.ts @@ -18,6 +18,7 @@ const options: any = { } }, jobs: [ + { name: 'test' }, { name: 'deployApplication', },