使用memcached运行服务器rails 2.3.5时出错

时间:2016-05-26 04:14:24

标签: ruby-on-rails ruby

我使用ruby版本1.8.7,gem版本1.3.5,rails版本2.3.5和memcache。我运行服务器时出现此错误

phuongnm-lap:~/trunk/hurricane$ ruby script/server
=> Booting Mongrel
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
/home/asiantech/.rvm/gems/ruby-1.8.7-p374/gems/bundler-1.11.2/lib/bundler/runtime.rb:77:in `require': /home/asiantech/trunk/hurricane/vendor/bundle/ruby/1.8/gems/get_process_mem-0.2.0/lib/get_process_mem.rb:60: undefined (?...) sequence: /(?<value>(\d*\.{0,1}\d+))\s+(?<unit>\w\w)/ (SyntaxError)
    from /home/asiantech/.rvm/gems/ruby-1.8.7-p374/gems/bundler-1.11.2/lib/bundler/runtime.rb:77:in `require'
    from /home/asiantech/.rvm/gems/ruby-1.8.7-p374/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
    from /home/asiantech/.rvm/gems/ruby-1.8.7-p374/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `require'
    from /home/asiantech/.rvm/gems/ruby-1.8.7-p374/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
    from /home/asiantech/.rvm/gems/ruby-1.8.7-p374/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
    from /home/asiantech/.rvm/gems/ruby-1.8.7-p374/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
    from ./script/../config/boot.rb:41:in `load_gems'
    from /home/asiantech/trunk/hurricane/vendor/bundle/ruby/1.8/gems/rails-2.3.5/lib/initializer.rb:164:in `process'
    from /home/asiantech/trunk/hurricane/vendor/bundle/ruby/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `send'
    from /home/asiantech/trunk/hurricane/vendor/bundle/ruby/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in `run'
    from /home/asiantech/trunk/hurricane/config/environment.rb:34
    from /home/asiantech/trunk/hurricane/vendor/bundle/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
    from /home/asiantech/trunk/hurricane/vendor/bundle/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
    from /home/asiantech/trunk/hurricane/vendor/bundle/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /home/asiantech/trunk/hurricane/vendor/bundle/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in `require'
    from /home/asiantech/trunk/hurricane/vendor/bundle/ruby/1.8/gems/rails-2.3.5/lib/commands/server.rb:84
    from script/server:3:in `require'
    from script/server:3

请帮助我!

1 个答案:

答案 0 :(得分:2)

您的ruby版本太旧而无法运行get_process_mem gem 。 gem使用complex regular expression来解析linux服务器上/proc文件的信息。但是,ruby 1.8.7还不支持这种复杂的正则表达式。

你可以在irb中看到自己。在红宝石1.8.7中,比赛失败了:

"aaa" =~ /(?<value>(\d*\.{0,1}\d+))\s+(?<unit>\w\w)/
# => SyntaxError: compile error
# => (irb):1: undefined (?...) sequence: /(?<value>(\d*\.{0,1}\d+))\s+(?<unit>\w\w)/

而在ruby 2.2下它可以正常工作(在这个测试用例中没有返回任何内容,但更重要的是,不会因错误而失败):

"aaa" =~ /(?<value>(\d*\.{0,1}\d+))\s+(?<unit>\w\w)/
# => nil

您现在有几个选择:

  • 如果可以的话,升级到更新的ruby(和rails),您不必解决这些与代码相关的老问题,并且不再使用不受支持的ruby / rails版本,但仍然如此这是一个繁琐的过程。
  • 摆脱get_process_mem宝石。您可以使用命令行实用程序查看相同的信息,即进程消耗的内存,而无需安装任何gem。 例如,尝试tophtop命令。