我在安装了Apache的Ubuntu服务器上使用乘客。
当我尝试使用redis加载ruby应用程序时,我收到此错误。
Error message:
uninitialized constant Redis::Client::ALIASES
Exception class:
NameError
Application root:
/xxx/ruby
0 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/redis-namespace-0.4.3/lib/redis/namespace.rb 128 in `'
1 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/redis-namespace-0.4.3/lib/redis/namespace.rb 4 in `'
2 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/redis-namespace-0.4.3/lib/redis/namespace.rb 3 in `'
3 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/resque-1.8.2/lib/resque.rb 1 in `'
4 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/resque-1.8.2/lib/resque/server.rb 3 in `'
5 /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/runtime.rb 68 in `require'
6 /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/runtime.rb 68 in `block (2 levels) in require'
7 /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/runtime.rb 66 in `each'
8 /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/runtime.rb 66 in `block in require'
9 /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/runtime.rb 55 in `each'
10 /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler/runtime.rb 55 in `require'
11 /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.3/lib/bundler.rb 119 in `require'
12 /xxx/ruby/config/application.rb 7 in `'
13 /xxx/ruby/config/environment.rb 4 in `require'
14 /xxx/ruby/config/environment.rb 4 in `'
15 config.ru 3 in `require'
16 config.ru 3 in `block in '
17 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb 51 in `instance_eval'
18 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb 51 in `initialize'
19 config.ru 1 in `new'
20 config.ru 1 in `'/usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/rack/application_spawner.rb 225 in `eval'
21 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/rack/application_spawner.rb 225 in `load_rack_app'
22 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/rack/application_spawner.rb 157 in `block in initialize_server'
23 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/utils.rb 572 in `report_app_init_status'
24 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/rack/application_spawner.rb 154 in `initialize_server'
25 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb 204 in `start_synchronously'
26 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb 180 in `start'
27 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/rack/application_spawner.rb 129 in `start'
28 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 253 in `block (2 levels) in spawn_rack_application'
29 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server_collection.rb 132 in `lookup_or_add'
30 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 246 in `block in spawn_rack_application'
31 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server_collection.rb 82 in `block in synchronize'
32 < td=""> <> prelude> 10:in `synchronize'
33 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server_collection.rb 79 in `synchronize'
34 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 244 in `spawn_rack_application'
35 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 137 in `spawn_application'
36 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/spawn_manager.rb 275 in `handle_spawn_application'
37 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb 357 in `server_main_loop'
38 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/lib/phusion_passenger/abstract_server.rb 206 in `start_synchronously'
39 /usr/local/rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.12/helper-scripts/passenger-spawn-server 99 in `'
这就是我的config.ru的样子。
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rack::URLMap.new \
"/" => xxx::Application,
"/resque" => Resque::Server.new
这就是我的resque_r.rb的样子(它位于config / initializers中)。
require "rubygems"
require 'resque_scheduler'
Resque.redis = 'localhost:6379'
Resque.redis.namespace = "resque:SchedulerExample"
# If you want to be able to dynamically change the schedule,
# uncomment this line. A dynamic schedule can be updated via the
# Resque::Scheduler.set_schedule (and remove_schedule) methods.
# When dynamic is set to true, the scheduler process looks for
# schedule changes and applies them on the fly.
# Note: This feature is only available in >=2.0.0.
Resque::Scheduler.dynamic = true
Dir["#{Rails.root}/app/workers/*.rb"].each { |file| require file }
# The schedule doesn't need to be stored in a YAML, it just needs to
# be a hash. YAML is usually the easiest.
Resque.schedule = YAML.load_file(Rails.root.join('config', 'resque_schedule.yml'))
我的宝石文件
source 'https://rubygems.org'
gem 'rails', '3.2.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', :require => 'sass'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platform => :ruby
gem 'uglifier', '>= 1.0.3'
gem 'compass-rails'
end
gem 'twitter-bootstrap-rails', "~> 2.0rc0"
gem 'jquery-rails'
gem 'feedzirra'
gem "friendly_id", "~> 4.0.1"
gem 'acts-as-taggable-on', '~> 2.2.2'
gem 'will_paginate', '~> 3.0'
gem 'gon'
gem 'wikitext'
gem 'twitter'
gem 'yaml_db'
#JSON PARSER
gem "oj", "~> 1.2.8"
gem "mysql2", "~> 0.3.11"
gem 'resque', :require => "resque/server"
gem 'resque-scheduler', :require => 'resque_scheduler'
# 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 'ruby-debug19', :require => 'ruby-debug'
答案 0 :(得分:1)
从堆栈跟踪中看起来,当它加载config.ru
时会发生错误。
您的config.ru文件中似乎没有包含resque/server
。
以下是我在其中一个项目中使用的配置:
require ::File.expand_path('../config/environment', __FILE__)
require 'resque/server'
run Rack::URLMap.new \
"/" => DmWorkflow::Application,
"/resque" => Resque::Server.new
此外,我不知道它是否会对您产生影响,但我将这些内容包含在我的Gemfile
中:
gem 'resque'
gem 'resque-loner'
gem 'resque-scheduler', ">= 2.0.0.h"
答案 1 :(得分:1)
您正在运行旧版resque
gem。 resque
redis-namespace
版本1.0.2
及更高版本上的新版redis-namespace
depends,但您的堆栈跟踪表明它加载了bundle update
v0.4.3。
尝试运行Gemfile
。如果版本仍然不正确,请添加到gem 'redis-namespace', '~> 1.0.2'
:
resque
或者,您可以通过git:
安装gem 'resque', github: 'defunkt/resque'
的边缘版本
{{1}}
答案 2 :(得分:1)
我不太明白你为明显解决这个问题做了什么,因为我相信它实际上是redis-namespace中的一个错误。请参阅issue #38。
答案 3 :(得分:0)
我在服务器上安装了错误的redis版本。而不是使用apt-get install redis-server,我手动安装了redis-server,解决了这个问题!