hubotio / hubot-redis-brain

A hubot script to persist hubot's brain using redis
69 stars 55 forks source link

Unable to use redis-brain via unix socket #8

Closed dictvm closed 7 years ago

dictvm commented 9 years ago

My environment requires I run redis via a unix socket, which is fully supported by the redis developers. However, I have so far failed to find a working REDIS_URL-string for this setup.

I have tried the following REDIS_URLs:

export REDIS_URL=unix:///home/hubot/.redis/sock
export REDIS_URL=unix:/home/hubot/.redis/sock
export REDIS_URL=redis+socket:/home/hubot/.redis/sock

According to various Google searches, export REDIS_URL=unix:/home/hubot/.redis/sockshould be the correct option.

Unfortunately, my hubot fails to connect to redis with any of these configurations, while redis itself is running perfectly fine :

$ redis-cli -s ~/.redis/sock
redis /home/hubot/.redis/sock>

$ redis-server --version
Redis server v=2.8.21 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=5d69a78d027f8932

During startup, hubot discovers the REDIS_URL (without performing any verification, I assume), but then does not nothing:

2015-09-02 03:40:20.450492500 [Wed Sep 02 2015 03:40:20 GMT+0200 (CEST)] INFO hubot-redis-brain: Discovered redis from REDIS_URL environment variable

when in fact I should be able to see something like this during first startup:

[...] Initializing new data for #{prefix} brain

At first I thought, I might simply lack the option to add the required prefix to a unix socket when using REDIS_URL. However, said prefix is meant to be optional and should default to "hubot", so I cannot imagine that this is the problem.

Any help is really appreciated. Thank you!

michaelansel commented 9 years ago

Maybe hubot-redis-brain is misusing the redis module and causing it to always attempt a TCP connection?

Looks like this is the relevant code bit: https://github.com/NodeRedis/node_redis/blob/master/index.js#L1233-L1255

technicalpickles commented 8 years ago

The problem is that this script parses the REDIS_URL to construct options to pass into Redis.createClient: https://github.com/hubot-scripts/hubot-redis-brain/blob/master/src/redis-brain.coffee#L38

I think it needs to check for a unix scheme, and pass in something different. Looking at https://github.com/NodeRedis/node_redis/blob/7922d4eb8552b287b30a18a744c9ab27674c12e5/index.js#L1140 I think the path to the socket is passed in as a string to 'port' (not sure how that makes sense).

ChrisCinelli commented 8 years ago

It looks like that aw worked on this. I created a pull request: https://github.com/hubot-scripts/hubot-redis-brain/pull/12 - But I suggest #14 for more options

ChrisCinelli commented 8 years ago

This should also fix it: https://github.com/hubot-scripts/hubot-redis-brain/pull/14

law commented 8 years ago

I am also having these issues, would love to see #14 merged if it fixes the problem.

elespike commented 7 years ago

@technicalpickles let's give hubot-redis-brain some love! I'd like to see #14 merged as well. Willing to help, if needed.

mose commented 7 years ago

The #12 was merged (well, code was merged, PR was not, my fault). I tested locally and it works fine.

:heart: :heart: :heart: