I'm running an app on heroku. The web worker is developed in the Grape framework.
As Grape doesn't have anything like config/initializers, I'm running a code like this before each access to Resque:
HEROKU_REDIS_URL = "redis://redistogo:[email protected]:9990/"
uri = URI.parse(HEROKU_REDIS_URL)
Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password, :thread_safe => false)
After a while the Resque worker stops picking up jobs from Redis, even though some are queued there. When running locally everything works fine.
Any idea what am I doing wrong? Or where should I put the Resque's Redis initialization?
So after quite a few hours of debugging I made it work. Let me share what parts were wrong in my setup:
Make sure redis is assigned to Resque only once both for web server and the worker process: I ended up with a code like this:
I placed it in app/resque_redis_init.rb and required both in the web app and the worker Rakefile in the
resque:setup
taskMake sure you're queuing the jobs in the right queues and that these have the right priority For me, it was the following setup in the Procfile
With this setup it works beautifully. Hope it helps somebody, as there are not much docs out there for non-rails apps.