Porting to DH: Rails 2.1, Ruby 1.8.7, IDE Netbeans 6.9.1


#1

Just completed an application, Ruby 1.8.7, Rails 2.1 in Netbeans 6.9.1. And I chose to deploy it via DH.

To deploy via DH host requires Passenger. Made that choice in DH Manage Domains. Have not been able to deploy. Seems that it is a matter of my boot.rb and environment.rb. But maybe it is a matter of the presence or absence of a GemFile with GemFile.lock. I don’t know. I have worked very hard here to understand what DH requires toward my successful deployment.

If this matter rings a bell with you, please let me know.

DH fails at Rails::Initializer.run in envornment.rb

My boot.rb, tried a boot.rb to just read from my gemFile, that didn’t work, so now I have placed the Netbeans generated:

RAILS_ROOT = “#{File.dirname(FILE)}/…” unless defined?(RAILS_ROOT)

module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end

def booted?
  defined? Rails::Initializer
end

def pick_boot
  (vendor_rails? ? VendorBoot : GemBoot).new
end

def vendor_rails?
  File.exist?("#{RAILS_ROOT}/vendor/rails")
end

def preinitialize
  load(preinitializer_path) if File.exist?(preinitializer_path)
end

def preinitializer_path
  "#{RAILS_ROOT}/config/preinitializer.rb"
end

end

class Boot
def run
load_initializer
Rails::Initializer.run(:set_load_path)
end
end

class VendorBoot < Boot
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
end
end

class GemBoot < Boot
def load_initializer
self.class.load_rubygems
load_rails_gem
require 'initializer’
end

def load_rails_gem
  if version = self.class.gem_version
    gem 'rails', version
  else
    gem 'rails'
  end
rescue Gem::LoadError => load_error
  $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
  exit 1
end

class << self
  def rubygems_version
    Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
  end

  def gem_version
    if defined? RAILS_GEM_VERSION
      RAILS_GEM_VERSION
    elsif ENV.include?('RAILS_GEM_VERSION')
      ENV['RAILS_GEM_VERSION']
    else
      parse_gem_version(read_environment_rb)
    end
  end

  def load_rubygems
    require 'rubygems'

    unless rubygems_version >= '0.9.4'
      $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
      exit 1
    end

  rescue LoadError
    $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
    exit 1
  end

  def parse_gem_version(text)
    $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
  end

  private
    def read_environment_rb
      File.read("#{RAILS_ROOT}/config/environment.rb")
    end
end

end
end

All that for this:

Rails.boot!

my environment.rb:

ENV[‘RAILS_ENV’] = 'production’
RAILS_GEM_VERSION = ‘2.1.0’ unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(FILE), ‘boot’)
require 'collaborator_values’
include CollaboratorValues
require ‘uuidtools’

Rails::Initializer.run do |config|
config.time_zone = ‘UTC’

config.load_paths += %W( #{RAILS_ROOT}/collaborator/source_files)

config.active_record.observers = :feature_observer, :alternative_observer, :user_observer
config.action_mailer.raise_delivery_errors = false
config.action_mailer.delivery_method = :smtp

config.action_mailer.smtp_settings = {
:enable_starttls_auto => false,
:address => “smtp.gmail.com” ,
:port => 587,
:domain => “gmail.com”,
:authentication => :login,
:user_name => "me@gmail.com",
:password => “password”
}

end

My Passenger Trace result:
/usr/lib/ruby/1.8/rubygems/custom_require.rb 31 in gem_original_require' 1 /usr/lib/ruby/1.8/rubygems/custom_require.rb 31 inrequire’
2 /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb 509 in require' 3 /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb 354 innew_constants_in’
4 /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb 509 in require' 5 /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb 101 inrequire_or_load’
6 /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb 60 in depend_on' 7 /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb 456 inrequire_dependency’
8 /usr/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb 18 in define_dispatcher_callbacks' 9 /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb 177 incall’
10 /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb 177 in evaluate_method' 11 /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb 161 incall’
12 /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb 90 in run' 13 /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb 90 ineach’
14 /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb 90 in send' 15 /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb 90 inrun’
16 /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/callbacks.rb 272 in run_callbacks' 17 /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb 483 insend’
18 /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb 483 in prepare_dispatcher' 19 /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb 151 inprocess’
20 /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb 93 in send' 21 /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb 93 inrun’
22 /home/green_rosa/greenrosa.com/config/environment.rb 19
23 /usr/lib/ruby/1.8/rubygems/custom_require.rb 31 in gem_original_require' 24 /usr/lib/ruby/1.8/rubygems/custom_require.rb 31 inrequire’
25 /dh/passenger/lib/phusion_passenger/classic_rails/application_spawner.rb 222 in preload_application' 26 /dh/passenger/lib/phusion_passenger/classic_rails/application_spawner.rb 181 ininitialize_server’
27 /dh/passenger/lib/phusion_passenger/utils.rb 563 in report_app_init_status' 28 /dh/passenger/lib/phusion_passenger/classic_rails/application_spawner.rb 174 ininitialize_server’
29 /dh/passenger/lib/phusion_passenger/abstract_server.rb 204 in start_synchronously' 30 /dh/passenger/lib/phusion_passenger/abstract_server.rb 180 instart’
31 /dh/passenger/lib/phusion_passenger/classic_rails/application_spawner.rb 149 in start' 32 /dh/passenger/lib/phusion_passenger/spawn_manager.rb 219 inspawn_rails_application’
33 /dh/passenger/lib/phusion_passenger/abstract_server_collection.rb 132 in lookup_or_add' 34 /dh/passenger/lib/phusion_passenger/spawn_manager.rb 214 inspawn_rails_application’
35 /dh/passenger/lib/phusion_passenger/abstract_server_collection.rb 82 in synchronize' 36 /dh/passenger/lib/phusion_passenger/abstract_server_collection.rb 79 insynchronize’
37 /dh/passenger/lib/phusion_passenger/spawn_manager.rb 213 in spawn_rails_application' 38 /dh/passenger/lib/phusion_passenger/spawn_manager.rb 132 inspawn_application’
39 /dh/passenger/lib/phusion_passenger/spawn_manager.rb 275 in handle_spawn_application' 40 /dh/passenger/lib/phusion_passenger/abstract_server.rb 357 insend
41 /dh/passenger/lib/phusion_passenger/abstract_server.rb 357 in server_main_loop' 42 /dh/passenger/lib/phusion_passenger/abstract_server.rb 206 instart_synchronously’
43 /dh/passenger/helper-scripts/passenger-spawn-server 99

Fails at line 24.
What have I done wrong?