简体   繁体   中英

Heroku with Sidekiq and Redis_To_Go

Trying to send emails with Sidekiq using Redis_To_Go, but my worker keeps crashing. I've done everything I could find, and I'm sure this is a small issue. Though I can't figure it out!

./Procfile.txt:

web: bundle exec rails server -p $PORT
worker: bundle exec sidekiq -c 5 -v

./config/initializers/redis.rb

$redis = Redis::Namespace.new("ihms_env_app", :redis => Redis.new)

uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(:url => ENV['REDISTOGO_URL'])

I've scaled the workers from 0 to 1

$ heroku ps
=== web (1X): `bin/rails server -p $PORT -e $RAILS_ENV`
web.1: up 2014/05/08 10:46:56 (~ 7m ago)

=== worker (1X): `bundle exec rake jobs:work`
worker.1: crashed 2014/05/08 10:47:00 (~ 7m ago)

log

heroku[worker.1]: State changed from crashed to starting
heroku[worker.1]: State changed from starting to up
heroku[worker.1]: Starting process with command `bundle exec rake jobs:work`
app[worker.1]: 
app[worker.1]: rake aborted!
app[worker.1]: Don't know how to build task 'jobs:work'

in console, I've run

heroku config:set REDIS_PROVIDER=REDISTOGO_URL

Hmm.

Your output from heroku ps and the logs indicates that you're trying, and failing, to run a rake task called "jobs:work".

What happens when you run: bundle exec rake jobs:work in your local directory? I'm going to guess it fails?

The Procfile you provide contradicts your logs. It has Sidekiq and not rake as the command. Are you sure you've checked it in to to your git repo and deployed it?

Looks like you need a conditional initializer in your redis.rb file, such as:

if ENV["REDISCLOUD_URL"]
    uri = URI.parse(ENV["REDISCLOUD_URL"])
    $redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
end

For more details, see my answer to Redis looking for env redis url variable not sure where to put env variable bad URI(is not URI?): (URI::InvalidURIError)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM