当前位置:  开发笔记 > 编程语言 > 正文

在Heroku Production网站上对Sidekiq工作人员进行故障诊断

如何解决《在HerokuProduction网站上对Sidekiq工作人员进行故障诊断》经验,为你挑选了1个好方法。

我一直在我的开发环境中测试我的sidekiq工作者,他们工作正常.然而,当我推到Heroku时,我似乎无法让我的工人开始.

我不确定解决此问题的最佳方法,但这里有一些信息:

Procfile:
web: bundle exec unicorn -p $PORT -E $RACK_ENV -c ./config/unicorn.rb

我没有sidekiq.yaml文件.

Unicorn.rb:
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 9999
preload_app true

before_fork do |server, worker|

  @sidekiq_pid ||= spawn("bundle exec sidekiq -c 2")
  Signal.trap 'TERM' do
    puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
    Process.kill 'QUIT', Process.pid
  end

  defined?(ActiveRecord::Base) and
      ActiveRecord::Base.connection.disconnect!
end
worker_processes 3

after_fork do |server, worker|

  Sidekiq.configure_client do |config|
    config.redis = { :size => 1 }
  end
  Sidekiq.configure_server do |config|
    config.redis = { :size => 5 }
  end

  Signal.trap 'TERM' do
    puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
  end

  defined?(ActiveRecord::Base) and
      ActiveRecord::Base.establish_connection
end

调用我的工人的佣金任务:

namespace :ivr do

  desc "For IVR"
  task get_welcome: :environment do
    NmeContactListWorker.perform_async('Welcome', 'IVR')
  end
end

当我调用这个rake任务时,我在heroku日志中得到以下内容:

2014-03-19T13:11:32.716759+00:00 heroku[api]: Starting process with command `bundle exec rake ivr:get_welcome` by test@gmail.com
2014-03-19T13:11:38.795843+00:00 heroku[run.3843]: State changed from starting to up
2014-03-19T13:11:38.711077+00:00 heroku[run.3843]: Awaiting client
2014-03-19T13:11:38.794029+00:00 heroku[run.3843]: Starting process with command `bundle exec rake ivr:get_welcome`
2014-03-19T13:11:47.171071+00:00 heroku[run.3843]: Process exited with status 0
2014-03-19T13:11:47.209653+00:00 heroku[run.3843]: State changed from up to complete

我不确定如何更好地了解我的工人失败的原因.什么可能导致这在Heroku的生产中发生,但在本地工作正常?



1> DiegoSalazar..:

在proc文件中,您需要启动sidekiq进程:

# Procfile
web: bundle exec unicorn -p $PORT -E $RACK_ENV -c ./config/unicorn.rb
worker: bundle exec sidekiq

实际上,这就是我们在dev机器上启动sidekiq,打开终端窗口并运行sidekiq命令.你的unicorn.rb只配置Sidekiq,而不是启动它.

注意:一旦部署,你必须在heroku上启动一个worker:

heroku ps:scale worker=1

推荐阅读
小白也坚强_177
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有