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

Redis in custom plugins #354

Closed
fuwaneko opened this issue Aug 22, 2013 · 4 comments
Closed

Redis in custom plugins #354

fuwaneko opened this issue Aug 22, 2013 · 4 comments

Comments

@fuwaneko
Copy link

When custom plugin uses redis, dns_list_base assumes that redis is available and tries to connect to localhost which leads to an error if redis is on separate machine. Disabling stats in dnsbl.ini/dnswl.ini does not help at all — dns_list_base still tries to connect to redis.

Either add redis configuration option to dns_list_base or option to disable redis functionality completely. Another option is handle the redis connection error (why didn't you do that? it throws and whole server dies!) and if connection could not be established, decide that local redis is not present after all.

Assuming availability based on sole npm module installed or not is horribly wrong.

@baudehlo
Copy link
Collaborator

FWIW we thought the error should be caught by the try/catch block, but the connection happens asynchronously so it throws from the event loop, crashing the server.

We now only try and connect to redis if stats are enabled. It also allows you to set the redis host. I'll push out 2.2.1 soon.

@fuwaneko
Copy link
Author

@baudehlo It's default "error" event handler in node-redis library that throws an exception. You could add custom handler which prevents exception from being thrown.

var redis = require("redis").createClient()
redis.on("error", function(error) {
  // redis is not available and no exception is thrown
})
redis.on("connected", function() {
  // redis is available
})

@baudehlo
Copy link
Collaborator

OK I've added in support for the error handler, but for now it just logs
the error.

The node redis library should re-try the connection if it fails, so I'll
just leave it like that.

On Thu, Aug 22, 2013 at 10:27 AM, Dmitry Gorbunov
notifications@github.comwrote:

@baudehlo https://github.com/baudehlo It's default "error" event
handler in node-redis library that throws an exception. You could add
custom handler which prevents exception from being thrown.

var redis = require("redis").createClient()
redis.on("error", function(error) {
// redis is not available and no exception is thrown
})
redis.on("connected", function() {
// redis is available
})


Reply to this email directly or view it on GitHubhttps://github.com/baudehlo/Haraka/issues/354#issuecomment-23094232
.

@fuwaneko
Copy link
Author

@baudehlo Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants