I am working on automating my Rails deploy with Capistrano and I am encountering an error at the end of the process while starting passenger. I end up with the following error :
uninitialized constant PhusionPassenger::Standalone::Command::SERVER_INSTANCE_DIR_STRUCTURE_MAJOR_VERSION
I actually found the SERVER_INSTANCE_DIR_STRUCTURE_MAJOR_VERSION
constant perfectly defined in [...]/phusion_passenger/constants.rb
.
Here is the complete stack trace:
*** [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>'
I added custom tasks for starting and stopping Passenger Standalone from Capistrano, and everything seems to go as expected including Passegner's installation, until this strange error. Here is the relevant part of my 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
My complete setup is as following :
One workaround would be to downgrade to Passenger 4.0.3.
gem uninstall passenger
gem install passenger --version="4.0.3"
It looks to be an issue in the 4.0.4 release.