Rails 5.2
redis 4.0.1
sidekiq 5.1.3
Heroku上的RedisToGo
Proc文件:
感谢任何帮助。
更新!根据这里的评论,以下是 heroku ps 的输出:
似乎某个工作人员由于某些原因崩溃了。
Heroku日志:
Heroku上的RedisToGo
Proc文件:
web: bundle exec puma -C config/puma.rb
worker: bundle exec sidekiq -e production -C config/sidekiq.yml
sidekiq.yml
development:
:concurrency: 5
production:
:concurrency: 6
:queues:
- default
config/initialize/sidekiq.rb
if Rails.env.production?
Sidekiq.configure_client do |config|
config.redis = { url: ENV['REDISTOGO_URL'] || ENV['REDIS_URL'], size: 1 }
end
Sidekiq.configure_server do |config|
pool_size = ENV['SIDEKIQ_DB_POOL'] || (Sidekiq.options[:concurrency] + 2)
config.redis = { url: ENV['REDISTOGO_URL'] || ENV['REDIS_URL'], size: pool_size }
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
db_config = Rails.application.config.database_configuration[Rails.env]
db_config['reaping_frequency'] = ENV['DATABASE_REAP_FREQ'] || 10 # seconds
db_config['pool'] = pool_size
ActiveRecord::Base.establish_connection(db_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
我不知道为什么作业被卡在队列中。该作业在我的本地开发环境中可以正常工作。感谢任何帮助。
更新!根据这里的评论,以下是 heroku ps 的输出:
=== web (Free): bundle exec puma -C config/puma.rb (1)
web.1: up 2018/06/15 18:49:56 +0700 (~ 5s ago)
=== worker (Free): bundle exec sidekiq -q default (1)
worker.1: crashed 2018/06/15 18:49:51 +0700 (~ 10s ago)
似乎某个工作人员由于某些原因崩溃了。
Heroku日志:
2018-06-15T11:56:00.301716+00:00 app[web.1]: [4] Puma starting in cluster mode...
2018-06-15T11:56:00.301740+00:00 app[web.1]: [4] * Version 3.11.2 (ruby 2.4.1-p111), codename: Love Song
2018-06-15T11:56:00.301760+00:00 app[web.1]: [4] * Min threads: 5, max threads: 5
2018-06-15T11:56:00.301794+00:00 app[web.1]: [4] * Environment: production
2018-06-15T11:56:00.301801+00:00 app[web.1]: [4] * Process workers: 2
2018-06-15T11:56:00.301838+00:00 app[web.1]: [4] * Preloading application
2018-06-15T11:56:01.249511+00:00 app[worker.1]: DB Connection Pool size for Sidekiq Server before disconnect is: 5
2018-06-15T11:56:01.252654+00:00 app[worker.1]: could not connect to server: No such file or directory
2018-06-15T11:56:01.252657+00:00 app[worker.1]: Is the server running locally and accepting
2018-06-15T11:56:01.252659+00:00 app[worker.1]: connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
heroku ps
命令来检查工作进程吗?也许这篇文章会有所帮助:https://dev59.com/w2Yr5IYBdhLWcg3wVYog - Artem Dorodovskyiheroku restart
。 - Artem Dorodovskyiheroku addons:create heroku-postgresql
将 Postgres 添加到您的 Heroku。 - Artem Dorodovskyi