ruby-on-rails - rake 请求 :workers command forks infinite processes

标签 ruby-on-rails ruby redis resque

我有一个 Rails 项目,它使用 resque worker,有一个像这样的 Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.5'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'

gem 'rest-open-uri'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails', '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'therubyracer' # If using Ruby
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
gem 'less-rails-bootstrap'

gem 'devise'

gem 'net-http-digest_auth', '1.2.1'

gem "resque", :require => "resque/server"

gem 'carrierwave'

gem 'kaminari'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

在我执行 bundle install 并尝试使用命令 rake resque:work QUEUE=checker_queuebundle exec rake resque:work 启动一些 resque worker QUEUE=checker_queue 我的机器停止响应(对任何东西)。当我使用 htop 观察系统时,我看到 rake 创建新进程,直到机器的内存和交换空间都已满(此时机器变得无响应)。

关于这种奇怪行为的原因有什么想法吗?

Redis 版本:

# redis-server -v
Redis server version 2.2.12 (00000000:0)

ruby 版本:

# ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]

Gemfile.lock:

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (3.2.15)
      actionpack (= 3.2.15)
      mail (~> 2.5.4)
    actionpack (3.2.15)
      activemodel (= 3.2.15)
      activesupport (= 3.2.15)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.4)
      rack (~> 1.4.5)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.2.1)
    activemodel (3.2.15)
      activesupport (= 3.2.15)
      builder (~> 3.0.0)
    activerecord (3.2.15)
      activemodel (= 3.2.15)
      activesupport (= 3.2.15)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.15)
      activemodel (= 3.2.15)
      activesupport (= 3.2.15)
    activesupport (3.2.15)
      i18n (~> 0.6, >= 0.6.4)
      multi_json (~> 1.0)
    arel (3.0.2)
    atomic (1.1.14)
    bcrypt-ruby (3.1.2)
    builder (3.0.4)
    carrierwave (0.9.0)
      activemodel (>= 3.2.0)
      activesupport (>= 3.2.0)
      json (>= 1.7)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.6.3)
    commonjs (0.2.7)
    devise (3.1.1)
      bcrypt-ruby (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 3.2.6, < 5)
      thread_safe (~> 0.1)
      warden (~> 1.2.3)
    erubis (2.7.0)
    execjs (2.0.2)
    hike (1.2.3)
    i18n (0.6.5)
    journey (1.0.4)
    jquery-rails (3.0.4)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    json (1.8.1)
    kaminari (0.14.1)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
    less (2.4.0)
      commonjs (~> 0.2.7)
    less-rails (2.4.2)
      actionpack (>= 3.1)
      less (~> 2.4.0)
    less-rails-bootstrap (3.0.4)
      less-rails (~> 2.4.2)
    libv8 (3.16.14.3)
    mail (2.5.4)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.25)
    mono_logger (1.1.0)
    multi_json (1.8.2)
    net-http-digest_auth (1.2.1)
    orm_adapter (0.4.0)
    polyglot (0.3.3)
    rack (1.4.5)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-protection (1.5.1)
      rack
    rack-ssl (1.3.3)
      rack
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (3.2.15)
      actionmailer (= 3.2.15)
      actionpack (= 3.2.15)
      activerecord (= 3.2.15)
      activeresource (= 3.2.15)
      activesupport (= 3.2.15)
      bundler (~> 1.0)
      railties (= 3.2.15)
    railties (3.2.15)
      actionpack (= 3.2.15)
      activesupport (= 3.2.15)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.14.6, < 2.0)
    rake (10.1.0)
    rdoc (3.12.2)
      json (~> 1.4)
    redis (3.0.5)
    redis-namespace (1.3.2)
      redis (~> 3.0.4)
    ref (1.0.5)
    resque (1.25.1)
      mono_logger (~> 1.0)
      multi_json (~> 1.0)
      redis-namespace (~> 1.2)
      sinatra (>= 0.9.2)
      vegas (~> 0.1.2)
    rest-open-uri (1.0.0)
    sass (3.2.12)
    sass-rails (3.2.6)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    sinatra (1.4.4)
      rack (~> 1.4)
      rack-protection (~> 1.4)
      tilt (~> 1.3, >= 1.3.4)
    sprockets (2.2.2)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sqlite3 (1.3.8)
    therubyracer (0.12.0)
      libv8 (~> 3.16.14.0)
      ref
    thor (0.18.1)
    thread_safe (0.1.3)
      atomic
    tilt (1.4.1)
    treetop (1.4.15)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.38)
    uglifier (2.3.0)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    vegas (0.1.11)
      rack (>= 1.0.0)
    warden (1.2.3)
      rack (>= 1.0)

PLATFORMS
  ruby

DEPENDENCIES
  carrierwave
  coffee-rails (~> 3.2.1)
  devise
  jquery-rails
  kaminari
  less-rails-bootstrap
  net-http-digest_auth (= 1.2.1)
  rails (= 3.2.15)
  resque
  rest-open-uri
  sass-rails (~> 3.2.3)
  sqlite3
  therubyracer
  uglifier (>= 1.0.3)

最佳答案

也许应用程序代码中有一个错误会安排重新请求作业,或者可能有很多待处理的作业,或者问题可能出在任务本身。在任何情况下也尝试检查resque状态:

   Resque.info
   Resque.size :medium

也许这将有助于确定问题

关于ruby-on-rails - rake 请求 :workers command forks infinite processes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19770941/

相关文章:

Phpredis 前置值——无法弄清楚为什么

javascript - 创建基本分析页面

ruby-on-rails - 从 Controller 参数中保存 Rails 模型?

ruby - 如何根据名称动态调用方法?

Ruby 字符串操作不适用于捕获的组

ruby-on-rails - HAML 语法错误中的 Rails 表单

Redis key - value 值的版本控制

ruby-on-rails - *显示* View 始终显示数据库中的第一个引脚(项目)

ruby-on-rails - 识别服务-IRC

ruby-on-rails - Rails错误: `method_missing' : undefined method `register_middleware'