gpt4 book ai didi

ruby-on-rails - Resque worker 默默地死去

转载 作者:可可西里 更新时间:2023-11-01 10:54:42 25 4
gpt4 key购买 nike

我为网站设置的工作人员遇到问题。这是应用程序的一些背景:它在 rails 3.0.2 上运行,使用 mongodb,redis gem 2.2.2。为了让 worker 保持正常运行,我设置了 god gem 并指定 6 个 worker 应该在生产环境中运行。我将在下面粘贴 resque.god.rb 文件。此外,还有一个专为 resque-workers 和 elasticsearch 服务设置的独特的 Ubuntu 服务器,因此它不共享任何其他服务。

我的问题是,出于任何原因,工作人员不断死去,只是在我的 log/resque-worker.log 文件中记录“*** Exiting ...”,这非常烦人,因为我不知道发生了什么上。它不会在 syslog 文件或 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 = 'XXXX@gmail.com'
d.server_password = 'XXXX'
end
end



God.contact(:email) do |c|
c.name = 'engineering'
c.group = 'developers'
c.to_email = 'engineering@something.com'
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

请告诉我您的想法。

最佳答案

看来我找到了问题的根源。在我的路线文件中,我添加了对方法的调用以加载一些动态路线,看起来 resque 不喜欢它,只是一直杀死进程而不说任何事情(仍然很奇怪)。然而,在删除该行 (DynamicRouter.load) 后,工作人员停止了这种疯狂的行为。我希望这对其他人有帮助,我很乐意提供更多关于我能找到的内容的详细信息。

关于ruby-on-rails - Resque worker 默默地死去,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46043701/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com