Class/Module Index [+]

Quicksearch

PhusionPassenger::Config::InstallationUtils

Public Class Methods

included(klass) click to toggle source
# File lib/phusion_passenger/config/installation_utils.rb, line 42
def self.included(klass)
  # When included into another class, make sure that Utils
  # methods are made private.
  public_instance_methods(false).each do |method_name|
    klass.send(:private, method_name)
  end
end

Public Instance Methods

check_for_download_tool!() click to toggle source
# File lib/phusion_passenger/config/installation_utils.rb, line 82
def check_for_download_tool!
  PlatformInfo::Depcheck.load('depcheck_specs/utilities')
  result = PlatformInfo::Depcheck.find('download-tool').check
  # Don't output anything if there is a download tool.
  # We want to be as quiet as possible.
  return if result && result[:found]

  colors = @colors || Utils::AnsiColors.new
  puts colors.ansi_colorize("<banner>Checking for basic prerequities...</banner>")
  puts

  runner = PlatformInfo::Depcheck::ConsoleRunner.new
  runner.add('download-tool')

  result = runner.check_all
  puts
  if !result
    puts "---------------------------------------"
    puts
    render_template 'installation_utils/download_tool_missing',
      :runner => runner
    abort
  end
end
find_or_create_writable_support_binaries_dir!() click to toggle source
# File lib/phusion_passenger/config/installation_utils.rb, line 50
def find_or_create_writable_support_binaries_dir!
  if File.exist?(PhusionPassenger.support_binaries_dir)
    result = directory_writable?(PhusionPassenger.support_binaries_dir)
    if result == true  # return value can be a SystemCallError
      return PhusionPassenger.support_binaries_dir
    end

    if Process.euid == 0
      if result == false
        print_installation_error_header
        render_template 'installation_utils/support_binaries_dir_not_writable_despite_running_as_root',
          :dir => PhusionPassenger.support_binaries_dir,
          :myself => myself
      else
        render_template 'installation_utils/unexpected_filesystem_problem',
          :dir => PhusionPassenger.support_binaries_dir,
          :exception => result
      end
      abort
    else
      return find_or_create_writable_user_support_binaries_dir!
    end
  else
    if Process.euid == 0
      mkdir_p_preserve_parent_owner(PhusionPassenger.support_binaries_dir)
      return PhusionPassenger.support_binaries_dir
    else
      return find_or_create_writable_user_support_binaries_dir!
    end
  end
end
rake() click to toggle source
# File lib/phusion_passenger/config/installation_utils.rb, line 121
def rake
  return "env NOEXEC_DISABLE=1 #{PlatformInfo.rake_command}"
end
run_rake_task!(target) click to toggle source
# File lib/phusion_passenger/config/installation_utils.rb, line 125
def run_rake_task!(target)
  total_lines = `#{rake} #{target} --dry-run STDERR_TO_STDOUT=1 2>&1`.split("\n").size - 1
  partial_backlog = ""
  logfile = PhusionPassenger::Utils::TmpIO.new("passenger-install-log",
    :mode => File::WRONLY, :unlink_immediately => false)

  begin
    command = "#{rake} #{target} --trace STDERR_TO_STDOUT=1 2>&1"
    IO.popen(command, "rb") do |io|
      progress = 1
      while !io.eof?
        line = io.readline
        logfile.write(line)
        yield(progress, total_lines)
        if line =~ /^\*\* /
          partial_backlog.replace("")
          progress += 1
        else
          partial_backlog << line
        end
      end
    end
    if $?.exitstatus != 0
      colors = @colors || PhusionPassenger::Utils::AnsiColors.new
      stderr = @stderr || STDERR
      stderr.puts
      stderr.puts "#{colors.red}*** ERROR: a Rake command failed. You can find the full " +
        "log in #{logfile.path}. Below, you can find the last few lines of the command's output.#{colors.reset}"
      stderr.puts "#{colors.red}------------- Begin command output snippet -------------#{colors.reset}"
      stderr.puts(partial_backlog)
      stderr.puts "#{colors.red}------------- End command output snippet -------------#{colors.reset}"
      stderr.puts "#{colors.red}The full log can be found in #{logfile.path}#{colors.reset}"
      exit 1
    end
  ensure
    logfile.close
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.