我正在尝试让我的 Rails 应用程序使用 Sidekiq 处理后台作业,并将 Sidekiq 与 Heroku 上的 redis-to-go 连接起来。这是我的Procfile
:
web: bundle exec puma -C config/puma.rb
worker: bundle exec -C config/sidekiq.yml
这是我的Sidekiq.rb
初始化程序文件:
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
该REDIS_PROVIDER
变量REDISTOGO_URL
在 Heroku 中设置为。根据此处提供的说明,我还添加了一个初始化程序文件redis.rb
。以下是内容:
uri = URI.parse(ENV["REDIS_PROVIDER"])
REDIS = Redis.new(:url => uri)
我收到以下错误,不知道如何解决。Heroku 也抛出了 H10 错误
[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)
更新:
我在 Heroku 上回滚到以前的版本并从 gemfile 中删除了 redis gem,删除了 redis 初始化文件,应用程序不再崩溃。但是后台作业仍然无法正常工作,并且我在日志中收到这些错误:
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`
为什么系统不接受导致worker崩溃的config参数?
无效uri方案的错误仍然存在:
app/web.1: Completed 500 Internal Server Error in 303ms (ActiveRecord: 0.0ms)
app/web.1: ArgumentError (invalid uri scheme ''):
sidekiq.yml 文件
# 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.
:超时: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
生产::并发:25 暂存::并发:10