6

I have a RoR app with background jobs using whenever and sidekiq gems.

In development environment when I launch sidekiq with local redis instance (on localhost) the job keeps getting executed without problems. But when I switch to a remote redis instance (Heroku add-on) and restart sidekiq, it says it started processing, but nothing happens and workers aren't doing any jobs.

Here's my config/schedule.rb (for whenever gem)

every 2.minutes do
  rake "crawler:crawl"
end

Here's my initializers/redis.rb:

Sidekiq.configure_server do |config|
  config.redis = { :url => 'redis://user:pass@spinyfin.redistogo.com:9098/' }
end

Sidekiq.configure_client do |config|
  config.redis = { :url => 'redis://user:pass@spinyfin.redistogo.com:9098/' }
end

If I comment out the content in redis.rb and run a local redis instance, the jobs are processed normally. But when I use this remote redis instance, this shows up and then nothing gets processed:

2013-11-29T15:09:26Z 95156 TID-ov6y7e14o INFO: Booting Sidekiq 2.13.0 using redis://redistogo:user@spinyfin.redistogo.com:9098/ with options {}
2013-11-29T15:09:26Z 95156 INFO: Running in ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin11.4.2]
2013-11-29T15:09:26Z 95156 INFO: See LICENSE and the LGPL-3.0 for licensing details.
2013-11-29T15:09:26Z 95156 INFO: Starting processing, hit Ctrl-C to stop
Matic Jurglič
  • 831
  • 9
  • 26

2 Answers2

1

Maybe you connecting to wrong redis database or not connected at all. In my apps I use redis url without trailing slash. In your case:

This is for database "0"

redis://user:pass@spinyfin.redistogo.com:9098

And this for database "1"

redis://user:pass@spinyfin.redistogo.com:9098/1
Andrey Artemyev
  • 452
  • 4
  • 11
1

I use the environment variable REDIS_URL to ensure that everything is using the same Redis.

Re: Heroku - I just read this here as I was searching for my own solution:

If you're running on Heroku, you can't rely on the config/database.yml as that platform relies on the DATABASE_URL environment variable to determine the database connection configuration. Heroku overwrites the database.yml during slug compilation so that it reads from DATABASE_URL.

Daniël W. Crompton
  • 3,448
  • 25
  • 26