【问题标题】:Passenger start fails with uninitialized constant error乘客启动失败,出现未初始化的常量错误
【发布时间】:2013-05-28 02:54:11
【问题描述】:

我正在使用 Capistrano 自动化我的 Rails 部署,并且在启动乘客时在流程结束时遇到错误。 我最终得到以下错误:

uninitialized constant PhusionPassenger::Standalone::Command::SERVER_INSTANCE_DIR_STRUCTURE_MAJOR_VERSION

我实际上发现SERVER_INSTANCE_DIR_STRUCTURE_MAJOR_VERSION 常量在[...]/phusion_passenger/constants.rb 中完美定义。

这是完整的堆栈跟踪:

*** [err :: www.example.com] /var/www/production/shared/bundle/ruby/1.9.1/gems/passenger-4.0.4/lib/phusion_passenger/standalone/command.rb:241:in `create_nginx_controller'
*** [err :: www.example.com] :
*** [err :: www.example.com] uninitialized constant PhusionPassenger::Standalone::Command::SERVER_INSTANCE_DIR_STRUCTURE_MAJOR_VERSION
*** [err :: www.example.com] (
*** [err :: www.example.com] NameError
*** [err :: www.example.com] )
*** [err :: www.example.com] from /var/www/production/shared/bundle/ruby/1.9.1/gems/passenger-4.0.4/lib/phusion_passenger/standalone/start_command.rb:69:in `run'
*** [err :: www.example.com] from /var/www/production/shared/bundle/ruby/1.9.1/gems/passenger-4.0.4/lib/phusion_passenger/standalone/main.rb:93:in `block in run_command'
*** [err :: www.example.com] from /var/www/production/shared/bundle/ruby/1.9.1/gems/passenger-4.0.4/lib/phusion_passenger/standalone/main.rb:48:in `block in each_command'
*** [err :: www.example.com] from /var/www/production/shared/bundle/ruby/1.9.1/gems/passenger-4.0.4/lib/phusion_passenger/standalone/main.rb:43:in `each'
*** [err :: www.example.com] from /var/www/production/shared/bundle/ruby/1.9.1/gems/passenger-4.0.4/lib/phusion_passenger/standalone/main.rb:43:in `each_command'
*** [err :: www.example.com] from /var/www/production/shared/bundle/ruby/1.9.1/gems/passenger-4.0.4/lib/phusion_passenger/standalone/main.rb:91:in `run_command'
*** [err :: www.example.com] from /var/www/production/shared/bundle/ruby/1.9.1/gems/passenger-4.0.4/lib/phusion_passenger/standalone/main.rb:62:in `run!'
*** [err :: www.example.com] from /var/www/production/shared/bundle/ruby/1.9.1/gems/passenger-4.0.4/lib/phusion_passenger/standalone/main.rb:39:in `run!'
*** [err :: www.example.com] from /var/www/production/shared/bundle/ruby/1.9.1/gems/passenger-4.0.4/bin/passenger:33:in `<top (required)>'
*** [err :: www.example.com] from /var/www/production/shared/bundle/ruby/1.9.1/bin/passenger:23:in `load'
*** [err :: www.example.com] from /var/www/production/shared/bundle/ruby/1.9.1/bin/passenger:23:in `<main>'

我添加了用于从 Capistrano 启动和停止Passenger Standalone 的自定义任务,一切似乎都按预期进行,包括 Passegner 的安装,直到出现这个奇怪的错误。这是我的 Capfile 的相关部分:

set :passenger_cmd,  "#{fetch(:bundle_cmd, "bundle")} exec passenger"
namespace :deploy do
  task :start, :roles => :app, :except => { :no_release => true } do
    run "cd #{current_path} && #{passenger_cmd} start -e #{rails_env} -p #{passenger_port} -d"
  end

  task :stop, :roles => :app, :except => { :no_release => true } do
    run "cd #{current_path} && #{passenger_cmd} stop -p #{passenger_port}"
  end

  task :restart, :roles => :app, :except => { :no_release => true } do
    run <<-CMD
      if [[ -f #{current_path}/tmp/pids/passenger.#{passenger_port}.pid ]];
      then
        cd #{current_path} && #{passenger_cmd} stop -p #{passenger_port};
      fi
    CMD

    run "cd #{current_path} && #{passenger_cmd} start -e #{rails_env} -p #{passenger_port} -d"
  end
end

我的完整设置如下:

  • Rails 3.2
  • RVM
  • 卡皮斯特拉诺
  • 独立乘客

【问题讨论】:

    标签: ruby-on-rails rvm capistrano passenger rvm-capistrano


    【解决方案1】:

    该错误已在 GitHub 上的提交 4ad928d 中修复。

    您可以尝试使用来自 GitHub 存储库的克隆,或等待包含此修复的版本 4.0.5。

    编辑:目前版本 4.0.5 可用。

    【讨论】:

      【解决方案2】:

      一种解决方法是降级到Passenger 4.0.3。

      gem uninstall passenger
      gem install passenger --version="4.0.3"
      

      这似乎是 4.0.4 版本中的一个问题。

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-02
      • 2016-03-05
      • 1970-01-01
      • 2011-10-04
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      相关资源
      最近更新 更多