Ruby on rails 工人未初始化Heroku+;Sidekiq+;博士后&x2B;再悬浮

Ruby on rails 工人未初始化Heroku+;Sidekiq+;博士后&x2B;再悬浮,ruby-on-rails,ruby,heroku,sidekiq,Ruby On Rails,Ruby,Heroku,Sidekiq,我正在尝试使用以下命令在Heroku worker中初始化Sidekiq: if Rails.env.production? Sidekiq.configure_client do |config| config.redis = { url: ENV['REDISCLOUD_URL'], size: 2 } end Sidekiq.configure_server do |config| config.redis = { url: ENV['REDISCLOUD_

我正在尝试使用以下命令在Heroku worker中初始化Sidekiq:

if Rails.env.production?

  Sidekiq.configure_client do |config|
    config.redis = { url: ENV['REDISCLOUD_URL'], size: 2 }
  end

  Sidekiq.configure_server do |config|
    config.redis = { url: ENV['REDISCLOUD_URL'], size: 10 }

    Rails.application.config.after_initialize do
      Rails.logger.info("DB Connection Pool size for Sidekiq Server before disconnect is: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}")
      ActiveRecord::Base.connection_pool.disconnect!

      ActiveSupport.on_load(:active_record) do
        config = Rails.application.config.database_configuration[Rails.env]
        config['reaping_frequency'] = ENV['DATABASE_REAP_FREQ'] || 10 # seconds
        # config['pool'] = ENV['WORKER_DB_POOL_SIZE'] || Sidekiq.options[:concurrency]
        config['pool'] = 8
        ActiveRecord::Base.establish_connection(config)

        Rails.logger.info("DB Connection Pool size for Sidekiq Server is now: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}")
      end
    end
  end

end  
但我的日志中有以下内容:

2017-04-12T22:33:20.435939+00:00 heroku[worker.1]: State changed from crashed to starting  
2017-04-12T22:33:23.510593+00:00 heroku[worker.1]: Starting process with command `bundle exec sidekiq -e production -C config/sidekiq.yml`  
2017-04-12T22:33:24.049032+00:00 heroku[worker.1]: State changed from starting to up  
2017-04-12T22:33:26.528756+00:00 app[worker.1]: 4 TID-otpsq87bc INFO: Booting Sidekiq 4.2.10 with redis options {:url=>"redis://rediscloud:REDACTED@redis-14870.c1.eu-west-1-3.ec2.cloud.redislabs.com:14870", :size=>20}  
2017-04-12T22:33:27.606408+00:00 heroku[worker.1]: State changed from up to crashed  
2017-04-12T22:33:27.590348+00:00 heroku[worker.1]: Process exited with status 1  
2017-04-12T22:33:27.506096+00:00 app[worker.1]: I, [2017-04-12T22:33:27.505980 #4]  INFO -- : DB Connection Pool size for Sidekiq Server before disconnect is: 5  
2017-04-12T22:33:27.509172+00:00 app[worker.1]: could not connect to server: Connection refused  
2017-04-12T22:33:27.509174+00:00 app[worker.1]:     Is the server running on host "localhost" (127.0.0.1) and accepting  
2017-04-12T22:33:27.509175+00:00 app[worker.1]:     TCP/IP connections on port 5432?

有人知道怎么回事吗?

它正在本地主机上寻找Postgres:5432

在Heroku上运行Sidekiq时,我也遇到了同样的问题。我通过在database.yml中的
production:
下面添加
url:
来修复它