在我的生产服务器上尝试使用Redis和Rails时,我一直收到LoadError / NameError
我的gemfile有require 'redis'
,我已经运行了bundle install
我的redis.rb初始化文件就像这样
require 'redis'
$redis = Redis.new(host: 'localhost', port: 6379)
但Unicorn正在LoadError
'行输出require 'redis
,如果我删除该行NameError
行Redis.new
这是LoadError
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- redis (LoadError)
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
from /home/anujan/apps/pentakilluniversity/releases/20130602154455/config/initializers/redis.rb:1:in `<top (required)>'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `block in load'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:587:in `each'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:587:in `block in <class:Engine>'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/anujan/apps/pentakilluniversity/releases/20130602154455/config/environment.rb:5:in `<top (required)>'
from config.ru:4:in `require'
from config.ru:4:in `block in <main>'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from config.ru:1:in `new'
from config.ru:1:in `<main>'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn.rb:44:in `eval'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn.rb:44:in `block in builder'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:722:in `call'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:722:in `build_app!'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:595:in `init_worker_process'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:615:in `worker_loop'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:500:in `spawn_missing_workers'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:511:in `maintain_worker_count'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:277:in `join'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/bin/unicorn:126:in `<top (required)>'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `load'
from /home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `<main>'
这是NameError
E, [2013-06-02T12:39:03.122148 #10042] ERROR -- : uninitialized constant Redis (NameError)
/home/anujan/apps/pentakilluniversity/releases/20130602163706/config/initializers/redis.rb:1:in `<top (required)>'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:587:in `each'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:587:in `block in <class:Engine>'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/anujan/apps/pentakilluniversity/releases/20130602163706/config/environment.rb:5:in `<top (required)>'
config.ru:4:in `require'
config.ru:4:in `block in <main>'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn.rb:44:in `eval'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn.rb:44:in `block in builder'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:722:in `call'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:722:in `build_app!'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:595:in `init_worker_process'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:615:in `worker_loop'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:500:in `spawn_missing_workers'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:511:in `maintain_worker_count'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:277:in `join'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/bin/unicorn:126:in `<top (required)>'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `load'
/home/anujan/apps/pentakilluniversity/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `<main>'