feat: Add logger for errors happened in queues

This commit is contained in:
Faruk AYDIN
2024-02-23 23:50:50 +01:00
parent fcf345abab
commit 00f5964aa4
6 changed files with 57 additions and 18 deletions

View File

@@ -15,11 +15,17 @@ process.on('SIGTERM', async () => {
await actionQueue.close();
});
actionQueue.on('error', (err) => {
if (err.code === CONNECTION_REFUSED) {
logger.error('Make sure you have installed Redis and it is running.', err);
actionQueue.on('error', (error) => {
if (error.code === CONNECTION_REFUSED) {
logger.error(
'Make sure you have installed Redis and it is running.',
error
);
process.exit();
}
logger.error('Error happened in action queue!', error);
});
export default actionQueue;

View File

@@ -15,11 +15,17 @@ process.on('SIGTERM', async () => {
await deleteUserQueue.close();
});
deleteUserQueue.on('error', (err) => {
if (err.code === CONNECTION_REFUSED) {
logger.error('Make sure you have installed Redis and it is running.', err);
deleteUserQueue.on('error', (error) => {
if (error.code === CONNECTION_REFUSED) {
logger.error(
'Make sure you have installed Redis and it is running.',
error
);
process.exit();
}
logger.error('Error happened in delete user queue!', error);
});
export default deleteUserQueue;

View File

@@ -15,11 +15,17 @@ process.on('SIGTERM', async () => {
await emailQueue.close();
});
emailQueue.on('error', (err) => {
if (err.code === CONNECTION_REFUSED) {
logger.error('Make sure you have installed Redis and it is running.', err);
emailQueue.on('error', (error) => {
if (error.code === CONNECTION_REFUSED) {
logger.error(
'Make sure you have installed Redis and it is running.',
error
);
process.exit();
}
logger.error('Error happened in email queue!', error);
});
export default emailQueue;

View File

@@ -15,11 +15,17 @@ process.on('SIGTERM', async () => {
await flowQueue.close();
});
flowQueue.on('error', (err) => {
if (err.code === CONNECTION_REFUSED) {
logger.error('Make sure you have installed Redis and it is running.', err);
flowQueue.on('error', (error) => {
if (error.code === CONNECTION_REFUSED) {
logger.error(
'Make sure you have installed Redis and it is running.',
error
);
process.exit();
}
logger.error('Error happened in flow queue!', error);
});
export default flowQueue;

View File

@@ -18,11 +18,20 @@ process.on('SIGTERM', async () => {
await removeCancelledSubscriptionsQueue.close();
});
removeCancelledSubscriptionsQueue.on('error', (err) => {
if (err.code === CONNECTION_REFUSED) {
logger.error('Make sure you have installed Redis and it is running.', err);
removeCancelledSubscriptionsQueue.on('error', (error) => {
if (error.code === CONNECTION_REFUSED) {
logger.error(
'Make sure you have installed Redis and it is running.',
error
);
process.exit();
}
logger.error(
'Error happened in remove cancelled subscriptions queue!',
error
);
});
removeCancelledSubscriptionsQueue.add('remove-cancelled-subscriptions', null, {

View File

@@ -15,11 +15,17 @@ process.on('SIGTERM', async () => {
await triggerQueue.close();
});
triggerQueue.on('error', (err) => {
if (err.code === CONNECTION_REFUSED) {
logger.error('Make sure you have installed Redis and it is running.', err);
triggerQueue.on('error', (error) => {
if (error.code === CONNECTION_REFUSED) {
logger.error(
'Make sure you have installed Redis and it is running.',
error
);
process.exit();
}
logger.error('Error happened in trigger queue!', error);
});
export default triggerQueue;