2017-09-04 18 views
1

나는 웹 사이트에 대해 설정 한 작업자에게 문제가 있습니다. 여기에 응용 프로그램의 배경이 있습니다 : mongodb, redis gem 2.2.2를 사용하여 레일 3.0.2에서 실행됩니다. 노동자를 계속 일하게하기 위해서 나는 하나님의 보석을 세우고 6 명의 노동자가 생산 환경에서 돌아 가야한다고 명시했다. resque.god.rb 파일을 붙여 넣습니다. 또한 resque-workers 및 elasticsearch 서비스 용으로 설정된 고유 한 우분투 서버 만 있으므로 다른 서비스를 공유하지 않습니다.Resque 작업자가 자동으로 사망 함

내 문제는 어떤 이유로 든 직원들이 계속 죽어 가며 내 로그/resque-worker.log 파일에 "*** Exiting ..."을 기록합니다. 이는 매우 까다로운 내용입니다. 계속. 그것은이 내가 로그 (나에게 도움이되지 않음)

*** Starting worker workers:19166:* 
*** Starting worker workers:19133:* 
*** Running before_first_fork hook 
*** Exiting... 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake/alt_system.rb:32: Use RbConfig instead of obsolete and deprecated Config. 
(in /data/www/tap-production/releases/20170904162514) 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `block in require': iconv will be deprecated in the future, use String#encode instead. 
*** Running before_first_fork hook 
*** Exiting... 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake/alt_system.rb:32: Use RbConfig instead of obsolete and deprecated Config. 
(in /data/www/tap-production/releases/20170904162514) 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `block in require': iconv will be deprecated in the future, use String#encode instead. 
*** Starting worker workers:19251:* 
*** Starting worker workers:19217:* 
*** Running before_first_fork hook 
*** Exiting... 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake/alt_system.rb:32: Use RbConfig instead of obsolete and deprecated Config. 
(in /data/www/tap-production/releases/20170904162514) 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `block in require': iconv will be deprecated in the future, use String#encode instead. 
*** Running before_first_fork hook 
*** Exiting... 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake/alt_system.rb:32: Use RbConfig instead of obsolete and deprecated Config. 
(in /data/www/tap-production/releases/20170904162514) 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `block in require': iconv will be deprecated in the future, use String#encode instead. 
*** Starting worker workers:19330:* 
*** Starting worker workers:19297:* 
*** Running before_first_fork hook 
*** Exiting... 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake/alt_system.rb:32: Use RbConfig instead of obsolete and deprecated Config. 
(in /data/www/tap-production/releases/20170904162514) 
/usr/local/www/tap-production/shared/bundle/ruby/1.9.1/gems/activesupport-3.0.20/lib/active_support/dependencies.rb:242:in `block in require': iconv will be deprecated in the future, use String#encode instead. 

가 여기 내 resque.god.rb 코드의에서 무엇을 얻을의 작품이다 syslog 파일이나 dmesg를

에 아무것도 기록하지 않습니다 :

require 'tlsmail' 
rails_env = ENV['RAILS_ENV'] 
rails_root = ENV['RAILS_ROOT'] 
rake_root = ENV['RAKE_ROOT'] 
num_workers = rails_env == 'production' ? 6 : 1 
# Change cache to my_killer_worker_job if you are testing in development. remember to enable it on config/resque_schedule.yml - Fabian 
queue = rails_env == 'production' ? '*' : 'my_killer_worker_job' 

God::Contacts::Email.defaults do |d| 
    Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE) 
    if rails_env == "production" 
    #Change this settings for your own purposes 
    d.from_name = "#{rails_env.upcase}: Process monitoring" 
    d.delivery_method = :smtp 
    d.server_host = 'smtp.gmail.com' 
    d.server_port = 587 
    d.server_auth = :login 
    d.server_domain = 'gmail.com' 
    d.server_user = '[email protected]' 
    d.server_password = 'XXXX' 
    end 
end 



God.contact(:email) do |c| 
    c.name = 'engineering' 
    c.group = 'developers' 
    c.to_email = '[email protected]' 
end 

num_workers.times do |num| 
    God.watch do |w| 
    w.name   = "resque-#{num}" 
    w.group   = 'resque' 
    w.interval  = 30.seconds 
    w.env   = { 'RAILS_ENV' => rails_env, 'QUEUE' => queue, 'VERBOSE' => '1' } 
    w.dir   = rails_root 
    w.start   = "bundle exeC#{rake_root}/rake resque:work" 
    w.start_grace = 10.seconds 
    w.log   = File.join(rails_root, 'log', 'resque-worker.log') 

    # restart if memory gets too high 
    w.transition(:up, :restart) do |on| 
     on.condition(:memory_usage) do |c| 
     c.above = 200.megabytes 
     c.times = 2 
     # c.notify = 'engineering' 
     end 
    end 

    # determine the state on startup 
    w.transition(:init, { true => :up, false => :start }) do |on| 
     on.condition(:process_running) do |c| 
     c.running = true 
     # c.notify = 'engineering' 
     end 
    end 

    # determine when process has finished starting 
    w.transition([:start, :restart], :up) do |on| 
     on.condition(:process_running) do |c| 
     c.running = true 
     c.interval = 5.seconds 
     # c.notify = 'engineering' 
     end 

     # failsafe 
     on.condition(:tries) do |c| 
     c.times = 5 
     c.transition = :start 
     c.interval = 5.seconds 
     # c.notify = 'engineering' 
     end 
    end 

    # start if process is not running 
    w.transition(:up, :start) do |on| 
     on.condition(:process_running) do |c| 
     c.running = false 
     c.notify = {:contacts => ['engineering'], :priority => 1, :category => "workers"} 
     end 
    end 


    end 
end 

의견을 보내주십시오.

+0

작업이 다른 위치에서 일부 텍스트를 출력하여 시도한 적이 있습니까? 또한, 이것은 프로덕션에서만 발생합니까? – MrYoshiji

+0

예, 수시로 다른 작업을 실행하는 작업자를 볼 수 있기 때문에 실행됩니다. 그리고 예, 생산 단계에서만 발생합니다. – fabianraf

답변

0

문제의 맨 아래에있는 것처럼 보입니다. 내 경로 파일에서 몇 가지 동적 경로를로드하기 위해 메소드에 대한 호출을 추가했으며 resque처럼 보이지 않았습니다. 아무 것도 말하지 않고 프로세스를 계속 종료했습니다. 그러나, 그 라인 (DynamicRouter.load)을 제거한 후에 작업자들은 미친 행동을 멈추었습니다. 나는 이것이 다른 누군가를 돕고, 내가 찾을 수있는 것에 대해 더 자세히 설명해 주길 바랍니다.