2017-09-04 94 views
1

我与我为一个网站设立的工人有问题。这里是应用程序的一些背景: 它运行在rails 3.0.2上,使用mongodb,redis gem 2.2.2。为了保持工人的正常运转,我设立了神灵宝石,并规定6名工人应该在生产环境中工作。我将粘贴下面的resque.god.rb文件。另外,还有一个独立的Ubuntu服务器,它只为resque-workers和elasticsearch服务设置,所以它不共享任何其他服务。Resque workers still silenceying sileying

我的问题是,出于任何原因,工作人员不断死亡,只是在日志/ resque-worker.log文件中记录“*** Exiting ...”,这是非常烦人的,因为我不知道什么是继续。它不记录在系统日志文件,也不dmesg的

什么这是一块什么,我的日志(对我来说没有什么帮助)

*** 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代码得到:

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)后,工作人员停止了疯狂行为。我希望这可以帮助别人,我会很乐意提供我能找到的更多细节。