Question

I'm attempting to send emails asynchronously to some users:

Here's the method chain that yesterday worked perfectly:

DiscussionMailer.delay.new_reply_notification()

Running this in the console appears to work perfectly, as it returns the worker id. I may be wrong that's what that key actually is, but as you can see, from the rails side of things everything's working.

2.0.0p247 :004 > DiscussionMailer.delay.new_reply_notification(User.last, Reply.last, Discussion.last, Forum.last )
  User Load (0.6ms)  SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT 1
  Reply Load (0.2ms)  SELECT "replies".* FROM "replies" ORDER BY "replies"."id" DESC LIMIT 1
  Discussion Load (0.2ms)  SELECT "discussions".* FROM "discussions" ORDER BY "discussions"."id" DESC LIMIT 1
  Forum Load (0.2ms)  SELECT "forums".* FROM "forums" ORDER BY "forums"."id" DESC LIMIT 1
2014-05-04T00:54:45Z 48591 TID-5s8e0 INFO: Sidekiq client with redis options {}
 => "3c35e763a23304e3f7e39e1e" 

However, it simply isn't. From experience and railgun logs, emails aren't getting anywhere near railgun. This appears to be because redis isn't doing anything:

               _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 2.6.13 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in stand alone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 48750
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

[48750] 04 May 02:02:48.687 # Server started, Redis version 2.6.13
[48750] 04 May 02:02:48.687 * DB loaded from disk: 0.001 seconds
[48750] 04 May 02:02:48.687 * The server is now ready to accept connections on port 6379

I should be getting some feedback, right?

I shutdown the redis server and attempt the same thing and I get:

    Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED)

This is good because it shows redis and sidekiq can communicate, but bad because what in gods name is going on? How should I debug this problem? railgun logs, and the rails log are both useless. Where can I find the redis logs? Or will that be no help either as the workers (or whatever they are, only learned about redis a few hours ago) aren't even 'reaching' redis?

Was it helpful?

Solution

The error message:

Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED)

is not Redis and Sidekiq communicating, it looks like your application's redis gem failing to communicate with a Redis server on port 6379 of your application's local host.

You need to start up your Redis server, and when that is up and running start your Sidekiq server. The process for starting each is dependent on your configuration of each.

As for your logs, when you start each of the servers you're going to want to export their outputs to a log file. So you should create an empty log file somewhere on your machine, and then when you go to start the server you modify your command as such:

 redis-server > /path/to/your/redis.log 2>&1

OTHER TIPS

Looks like you haven't started/restarted the sidekiq. Do it , it will work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top