Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #122: add logging to inform user of Redis connection failure #553

Merged
merged 4 commits into from
Jan 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/backend/lib/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ const { logger } = require('../utils/logger');
const client = createRedisClient();
const subscriber = createRedisClient();

/**
* Tracks whether an informative message has been logged following a Redis connection failure
*/
let redisConnectionRefusalLogged = false;

/**
* Create a Queue with the given `name` (String).
* We create a Bull Queue using either a real or mocked
Expand All @@ -31,7 +36,16 @@ function createQueue(name) {
})
.on('error', err => {
// An error occurred
logger.error({ err }, `Queue ${name} error`);
if (err.code === 'ECONNREFUSED' && !redisConnectionRefusalLogged) {
logger.error(
'\n\n\t💡 It appears that Redis is not running on your machine.',
Silvyre marked this conversation as resolved.
Show resolved Hide resolved
'\n\t Please see our documentation for how to install and run Redis:',
'\n\t https://github.com/Seneca-CDOT/telescope/blob/master/docs/CONTRIBUTING.md\n'
);
redisConnectionRefusalLogged = true;
} else {
logger.error({ err }, `Queue ${name} error`);
}
})
.on('waiting', jobID => {
// A job is waiting for the next idling worker
Expand Down