diff --git a/server/src/worker.ts b/server/src/worker.ts index a17d3bde..a45e525f 100644 --- a/server/src/worker.ts +++ b/server/src/worker.ts @@ -12,51 +12,51 @@ import { googleSheetUpdateTasks, processGoogleSheetUpdates } from "./workflow-ma import { handleRunRecording } from "./workflow-management/scheduler"; const connection = new IORedis({ - host: 'localhost', - port: 6379, - maxRetriesPerRequest: null, + host: 'localhost', + port: 6379, + maxRetriesPerRequest: null, }); connection.on('connect', () => { - console.log('Connected to Redis!'); + console.log('Connected to Redis!'); }); connection.on('error', (err) => { - console.error('Redis connection error:', err); + console.error('Redis connection error:', err); }); const workflowQueue = new Queue('workflow', { connection }); const worker = new Worker('workflow', async job => { - const { fileName, runId } = job.data; - try { - const result = await handleRunRecording(fileName, runId); - return result; - } catch (error) { - logger.error('Error running workflow:', error); - throw error; - } + const { fileName, runId } = job.data; + try { + const result = await handleRunRecording(fileName, runId); + return result; + } catch (error) { + 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.fileName}_${job.data.runId}`); + logger.log(`info`, `Job ${job.id} completed for ${job.data.fileName}_${job.data.runId}`); - await worker.close(); - await workflowQueue.close(); - logger.log(`info`, `Worker and queue have been closed.`); + await worker.close(); + await workflowQueue.close(); + logger.log(`info`, `Worker and queue have been closed.`); }); worker.on('failed', async (job: any, err) => { - logger.log(`error`, `Job ${job.id} failed for ${job.data.fileName}_${job.data.runId}:`, err); + logger.log(`error`, `Job ${job.id} failed for ${job.data.fileName}_${job.data.runId}:`, err); - await worker.close(); - await workflowQueue.close(); - logger.log(`info`, `Worker and queue have been closed after failure.`); + await worker.close(); + await workflowQueue.close(); + logger.log(`info`, `Worker and queue have been closed after failure.`); }); async function jobCounts() { - const jobCounts = await workflowQueue.getJobCounts(); - console.log('Jobs:', jobCounts); + const jobCounts = await workflowQueue.getJobCounts(); + console.log('Jobs:', jobCounts); } jobCounts();