chore: prettier
This commit is contained in:
@@ -12,51 +12,51 @@ import { googleSheetUpdateTasks, processGoogleSheetUpdates } from "./workflow-ma
|
|||||||
import { handleRunRecording } from "./workflow-management/scheduler";
|
import { handleRunRecording } from "./workflow-management/scheduler";
|
||||||
|
|
||||||
const connection = new IORedis({
|
const connection = new IORedis({
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: 6379,
|
port: 6379,
|
||||||
maxRetriesPerRequest: null,
|
maxRetriesPerRequest: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
connection.on('connect', () => {
|
connection.on('connect', () => {
|
||||||
console.log('Connected to Redis!');
|
console.log('Connected to Redis!');
|
||||||
});
|
});
|
||||||
|
|
||||||
connection.on('error', (err) => {
|
connection.on('error', (err) => {
|
||||||
console.error('Redis connection error:', err);
|
console.error('Redis connection error:', err);
|
||||||
});
|
});
|
||||||
|
|
||||||
const workflowQueue = new Queue('workflow', { connection });
|
const workflowQueue = new Queue('workflow', { connection });
|
||||||
|
|
||||||
const worker = new Worker('workflow', async job => {
|
const worker = new Worker('workflow', async job => {
|
||||||
const { fileName, runId } = job.data;
|
const { fileName, runId } = job.data;
|
||||||
try {
|
try {
|
||||||
const result = await handleRunRecording(fileName, runId);
|
const result = await handleRunRecording(fileName, runId);
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Error running workflow:', error);
|
logger.error('Error running workflow:', error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}, { connection });
|
}, { connection });
|
||||||
|
|
||||||
worker.on('completed', async (job: any) => {
|
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 worker.close();
|
||||||
await workflowQueue.close();
|
await workflowQueue.close();
|
||||||
logger.log(`info`, `Worker and queue have been closed.`);
|
logger.log(`info`, `Worker and queue have been closed.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
worker.on('failed', async (job: any, err) => {
|
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 worker.close();
|
||||||
await workflowQueue.close();
|
await workflowQueue.close();
|
||||||
logger.log(`info`, `Worker and queue have been closed after failure.`);
|
logger.log(`info`, `Worker and queue have been closed after failure.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
async function jobCounts() {
|
async function jobCounts() {
|
||||||
const jobCounts = await workflowQueue.getJobCounts();
|
const jobCounts = await workflowQueue.getJobCounts();
|
||||||
console.log('Jobs:', jobCounts);
|
console.log('Jobs:', jobCounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
jobCounts();
|
jobCounts();
|
||||||
|
|||||||
Reference in New Issue
Block a user