问题
I'm trying to get my Rails app to process background jobs with Sidekiq and to connect Sidekiq with redis-to-go on Heroku. Here's my Procfile
:
web: bundle exec puma -C config/puma.rb
worker: bundle exec -C config/sidekiq.yml
Here's my the Sidekiq.rb
intializer file:
require 'sidekiq'
Sidekiq.configure_client do |config|
config.redis = { url: ENV['REDIS_PROVIDER'] }
end
Sidekiq.configure_client do |config|
config.redis = { url: ENV['REDIS_PROVIDER'] }
end
The REDIS_PROVIDER
variable is set to REDISTOGO_URL
in Heroku. Per the instructions provided here I added an intializer file redis.rb
as well. Here are the contents:
uri = URI.parse(ENV["REDIS_PROVIDER"])
REDIS = Redis.new(:url => uri)
I'm getting the following error and not sure how to resolve it. Heroku is also throwing an H10 error
[3] ! Unable to load application: ArgumentError: invalid uri scheme '
/app/vendor/bundle/ruby/2.2.0/gems/redis-3.3.0/lib/redis/client.rb:416:in `_parse_options': invalid uri scheme '' (ArgumentError)
UPDATE:
I rolled back to a previous version on Heroku and removed the redis gem from the gemfile, removed the redis intializer file, and the app is no longer crashing. However background jobs still aren't working and I'm getting these errors in the log:
heroku/worker.1: Starting process with command `bundle exec -C config/sidekiq.yml`
heroku/worker.1: State changed from starting to up
app/worker.1: bundler: command not found: -C
heroku/worker.1: Process exited with status 127
heroku/worker.1: State changed from up to crashed
app/worker.1: Install missing gem executables with `bundle install`
Why is the system not accepting the config parameter causing the worker to crash?
The error of the invalid uri scheme persists:
app/web.1: Completed 500 Internal Server Error in 303ms (ActiveRecord: 0.0ms)
app/web.1: ArgumentError (invalid uri scheme ''):
sidekiq.yml file
# Sample configuration file for Sidekiq.
# Options here can still be overridden by cmd line args.
# Place this file at config/sidekiq.yml and Sidekiq will
# pick it up automatically.
---
:verbose: false
:concurrency: 10
# Set timeout to 8 on Heroku, longer if you manage your own systems.
:timeout: 8
# Sidekiq will run this file through ERB when reading it so you can
# even put in dynamic logic, like a host-specific queue.
# http://www.mikeperham.com/2013/11/13/advanced-sidekiq-host-specific-queues/
:queues:
- critical
- default
- low
# you can override concurrency based on environment
production: :concurrency: 25 staging: :concurrency: 10
回答1:
You are using REDIS_PROVIDER incorrectly. Please review the documentation again.
https://github.com/mperham/sidekiq/wiki/Using-Redis#using-an-env-variable
来源:https://stackoverflow.com/questions/38754179/heroku-error-argumenterror-invalid-uri-scheme