chore: lint
This commit is contained in:
@@ -3,56 +3,56 @@ import IORedis from 'ioredis';
|
|||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
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', () => {
|
|
||||||
console.log('Connected to Redis!');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
connection.on('error', (err) => {
|
connection.on('connect', () => {
|
||||||
console.error('Redis connection error:', err);
|
console.log('Connected to Redis!');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connection.on('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 { runId, userId } = job.data;
|
const { runId, userId } = job.data;
|
||||||
try {
|
try {
|
||||||
const result = await handleRunRecording(runId, userId);
|
const result = await handleRunRecording(runId, userId);
|
||||||
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.runId}`);
|
logger.log(`info`, `Job ${job.id} completed for ${job.data.runId}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
worker.on('failed', async (job: any, err) => {
|
worker.on('failed', async (job: any, err) => {
|
||||||
logger.log(`error`, `Job ${job.id} failed for ${job.data.runId}:`, 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() {
|
async function jobCounts() {
|
||||||
const jobCounts = await workflowQueue.getJobCounts();
|
const jobCounts = await workflowQueue.getJobCounts();
|
||||||
console.log('Jobs:', jobCounts);
|
console.log('Jobs:', jobCounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
jobCounts();
|
jobCounts();
|
||||||
|
|
||||||
process.on('SIGINT', () => {
|
process.on('SIGINT', () => {
|
||||||
console.log('Worker shutting down...');
|
console.log('Worker shutting down...');
|
||||||
process.exit();
|
process.exit();
|
||||||
});
|
});
|
||||||
|
|
||||||
export { workflowQueue, worker };
|
export { workflowQueue, worker };
|
||||||
|
|
||||||
export const temp = () => {
|
export const temp = () => {
|
||||||
console.log('temp');
|
console.log('temp');
|
||||||
|
|||||||
Reference in New Issue
Block a user