From 0af80adf93b99600bfc8967fed5c0c1c969e3694 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Tue, 22 Oct 2024 16:58:48 +0530 Subject: [PATCH] fix: uncomment workflowQueue code --- server/src/worker.ts | 76 +++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/server/src/worker.ts b/server/src/worker.ts index baef2387..12473fc2 100644 --- a/server/src/worker.ts +++ b/server/src/worker.ts @@ -3,53 +3,57 @@ import IORedis from 'ioredis'; import logger from './logger'; import { handleRunRecording } from "./workflow-management/scheduler"; -const connection = new IORedis({ - host: 'localhost', - port: 6379, - maxRetriesPerRequest: null, + const connection = new IORedis({ + host: 'localhost', + port: 6379, + maxRetriesPerRequest: null, + }); + + connection.on('connect', () => { + console.log('Connected to Redis!'); }); -connection.on('connect', () => { - console.log('Connected to Redis!'); -}); - -connection.on('error', (err) => { - console.error('Redis connection error:', err); -}); + connection.on('error', (err) => { + console.error('Redis connection error:', err); + }); const workflowQueue = new Queue('workflow', { connection }); -const worker = new Worker('workflow', async job => { - const { runId, userId } = job.data; - try { - const result = await handleRunRecording(runId, userId); + const worker = new Worker('workflow', async job => { + const { runId, userId } = job.data; + try { + const result = await handleRunRecording(runId, userId); return result; } catch (error) { - logger.error('Error running workflow:', error); - throw error; - } -}, { connection }); + logger.error('Error running workflow:', error); + throw error; + } + }, { connection }); -worker.on('completed', async (job: any) => { - logger.log(`info`, `Job ${job.id} completed for ${job.data.runId}`); -}); + worker.on('completed', async (job: any) => { + logger.log(`info`, `Job ${job.id} completed for ${job.data.runId}`); + }); -worker.on('failed', async (job: any, err) => { - logger.log(`error`, `Job ${job.id} failed for ${job.data.runId}:`, err); -}); + worker.on('failed', async (job: any, err) => { + logger.log(`error`, `Job ${job.id} failed for ${job.data.runId}:`, err); + }); -console.log('Worker is running...'); + console.log('Worker is running...'); -async function jobCounts() { - const jobCounts = await workflowQueue.getJobCounts(); - console.log('Jobs:', jobCounts); -} + async function jobCounts() { + const jobCounts = await workflowQueue.getJobCounts(); + console.log('Jobs:', jobCounts); + } -jobCounts(); + jobCounts(); -process.on('SIGINT', () => { - console.log('Worker shutting down...'); - process.exit(); -}); + process.on('SIGINT', () => { + console.log('Worker shutting down...'); + process.exit(); + }); -export { workflowQueue, worker }; \ No newline at end of file + export { workflowQueue, worker }; + +export const temp = () => { + console.log('temp'); +} \ No newline at end of file