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', },