0

我是 Ruby on Rails 的新手,并且继承了一个相当大的遗留应用程序,我需要在开发环境中运行它。我从头开始创建了一个 OSX Mountain Lion 虚拟机用作我的开发盒。我正在使用 ruby​​ 1.8.7 和 rails 2.2.2 运行。我为 apache2 安装了最新的 phusion 乘客模块。

尝试在 Safari 中加载应用程序时,我收到了这个非常通用的错误消息。apache 日志没有显示任何内容,rails 应用程序的日志没有显示任何内容。似乎很明显,在启动时没有找到一些 gem,并且 init 阶段正在中止。还是 RubyGems 本身不是正确的版本?

同样的应用程序可以使用ruby​​ 脚本/服务器运行,我可以在 Web 浏览器中运行其他 Rails 应用程序,所以这个特定的应用程序似乎有些东西。

有什么方法可以让我看到更多隐藏在引擎盖下的细节吗?似乎我应该能够访问关键错误消息,该消息会告诉我究竟是什么阻止了应用程序启动。我希望看到某些特定的宝石不存在或其他东西。或者这个回溯是否说了一些我不明白的非常明显的事情?

非常感谢您的帮助。

保罗。

附加说明:

刚刚尝试过单独的乘客(乘客在我的应用程序目录中启动)并且应用程序出现在浏览器中(减去一些静态图像)。这是否说明了我的 apache 配置?

错误信息:

Ruby on Rails application could not be started
Phusion Passenger has listed more information about the error below

The aplication has exited during startup (i.e. during the evaluation
of config/environment.rb). The error message may have been written to
the web server's log file. Please check the web server's log file
(i.e. not the (Rails) application's log file) to find out why the
application exited. If that doesn't help, then please use the
backtrace below to debug the problem.

Application root:
/Users/paul/Code/Site4/www_app
Backtrace:
#   File    Line    Location
0   /Users/paul/Code/Site4/www_app/config/environment.rb    29  in `exit'
1   /Users/paul/Code/Site4/www_app/config/environment.rb    29  
2   /Users/paul/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb   36  in `gem_original_require'
3   /Users/paul/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb   36  in `require'
4   /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/classic_rails/application_spawner.rb  222 in `preload_application'
5   /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/classic_rails/application_spawner.rb  181 in `initialize_server'
6   /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/utils.rb  563 in `report_app_init_status'
7   /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/classic_rails/application_spawner.rb  174 in `initialize_server'
8   /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb    204 in `start_synchronously'
9   /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb    180 in `start'
10  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/classic_rails/application_spawner.rb  149 in `start'
11  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb  219 in `spawn_rails_application'
12  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server_collection.rb 132 in `lookup_or_add'
13  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb  214 in `spawn_rails_application'
14  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server_collection.rb 82  in `synchronize'
15  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server_collection.rb 79  in `synchronize'
16  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb  213 in `spawn_rails_application'
17  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb  132 in `spawn_application'
18  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/spawn_manager.rb  275 in `handle_spawn_application'
19  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb    357 in `__send__'
20  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb    357 in `server_main_loop'
21  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/lib/phusion_passenger/abstract_server.rb    206 in `start_synchronously'
22  /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/helper-scripts/passenger-spawn-server   99  

阿帕奇配置:

LoadModule passenger_module /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
PassengerRoot /Users/paul/.rvm/gems/ruby-1.8.7-p371/gems/passenger-3.0.19
PassengerRuby /Users/paul/.rvm/wrappers/ruby-1.8.7-p371/ruby

<Directory "/Users/paul/Code">
    Order allow,deny
    Allow from all
</Directory>

NameVirtualHost *:80

<VirtualHost *:80>
    RailsEnv development
    ServerName www.local.com
    DocumentRoot /Users/paul/Code/Site4/www_app/public
    <Directory /Users/paul/Code/Site4/www_app/public>
       AllowOverride all
       Options -MultiViews
    </Directory>
 </VirtualHost>

其他版本的东西:

rvm list

rvm rubies

=* ruby-1.8.7-p371 [ i686 ]

# => - current
# =* - current && default
#  * - default

DBDev:~ paul$ gem --version
1.8.25
DBDev:~ paul$ rails --version
Rails 2.2.2

宝石清单:

*** LOCAL GEMS ***

actionmailer (2.2.2)
actionpack (2.2.2)
activemerchant (1.4.1)
activemodel (3.2.11)
activerecord (2.2.2)
activeresource (2.2.2)
activesupport (3.2.11, 2.2.2)
archive-tar-minitar (0.5.2)
archive-zip (0.3.0)
arel (3.0.2)
builder (3.1.4, 3.0.4)
bundler (1.2.3)
daemon_controller (1.1.1)
deep_merge (0.1.0)
differ (0.1.1)
fastercsv (1.5.0)
fastthread (1.0.7)
haml (2.2.5)
i18n (0.6.1)
io-like (0.3.0)
multi_json (1.5.0)
mysql (2.9.0)
paperclip (2.3.5)
passenger (3.0.19)
rack (1.5.2, 1.5.1)
rails (2.2.2)
rake (10.0.3, 0.8.7)
rmagick (2.13.2)
rubygems-bundler (1.1.0)
rvm (1.11.3.6)
sqlite3 (1.3.7)
tzinfo (0.3.35)
will_paginate (2.3.16)

宝石环境:

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.25
  - RUBY VERSION: 1.8.7 (2012-10-12 patchlevel 371) [i686-darwin12.2.1]
  - INSTALLATION DIRECTORY: /Users/paul/.rvm/gems/ruby-1.8.7-p371
  - RUBY EXECUTABLE: /Users/paul/.rvm/rubies/ruby-1.8.7-p371/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/paul/.rvm/gems/ruby-1.8.7-p371/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-darwin-12
  - GEM PATHS:
     - /Users/paul/.rvm/gems/ruby-1.8.7-p371
     - /Users/paul/.rvm/gems/ruby-1.8.7-p371@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

environment.rb 文件:

# Be sure to restart your server when you modify this file

# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'
ENV['RAILS_ENV'] = 'development'

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

# Global libraries
#require 'rubygems'
gem 'activemerchant', '=1.4.1'
require 'active_merchant'
require 'deep_merge'
require 'fastercsv'
require 'paperclip'

require 'digest/sha1'
require 'net/http'
require 'uri'

# Default host/app types.
if ENV['DEB_HOST_TYPE'].to_s.strip.empty? then
  puts 'ERROR: Environment variable DEB_HOST_TYPE is not set!  (Did you remember to export it?)  Exiting ...'
  exit 1
end
$DEB_HOST_TYPE = ENV['DEB_HOST_TYPE']
$DEB_APP_TYPE = 'admin'

Rails::Initializer.run do |config|
  config.time_zone = 'UTC'
  config.active_record.colorize_logging = false
  config.action_controller.session_store = :active_record_store
end
4

1 回答 1

0

在 environment.rb 文件的行中发现了问题:

# Default host/app types.
if ENV['DEB_HOST_TYPE'].to_s.strip.empty? then
  puts 'ERROR: Environment variable DEB_HOST_TYPE is not set!  (Did you remember to export it?)  Exiting ...'
  exit 1
end

环境变量确实为空,因此正在调用出口。puts 字符串从未出现在我看到的任何东西中。终于进去编辑了exit,得到了nil不能转成字符串的错误。我将 ENV['DEB_HOST_TYPE'] 的值硬编码为应有的值,现在应用程序运行了。

还想提一下,当我将 puts 更改为 $stderr.puts 时,该消息显示在乘客生成的错误页面上。

于 2013-02-14T04:52:43.423 回答