Class/Module Index [+]

Quicksearch

PhusionPassenger::Config::Utils

Public Class Methods

included(klass) click to toggle source
# File lib/phusion_passenger/config/utils.rb, line 32
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

complain_that_multiple_passenger_instances_are_running(instances) click to toggle source
# File lib/phusion_passenger/config/utils.rb, line 97
def complain_that_multiple_passenger_instances_are_running(instances)
  puts "It appears that multiple #{PROGRAM_NAME} instances are running. Please select"
  puts "a specific one by passing:"
  puts
  puts "  --instance <NAME>"
  puts
  list_all_passenger_instances(instances)
  abort
end
is_enterprise?() click to toggle source
# File lib/phusion_passenger/config/utils.rb, line 154
def is_enterprise?
  return defined?(PhusionPassenger::PASSENGER_IS_ENTERPRISE) && PhusionPassenger::PASSENGER_IS_ENTERPRISE
end
list_all_passenger_instances(instances) click to toggle source
# File lib/phusion_passenger/config/utils.rb, line 107
def list_all_passenger_instances(instances)
  puts "The following #{PROGRAM_NAME} instances are running:"
  puts
  printf "%-25s  %s\n", "Name", "Description"
  puts "------------------------------------------------------------------"
  if instances.empty?
    printf "%-25s  %s\n", "(list empty)", "-"
  else
    instances.each do |instance|
      printf "%-25s  %s\n", instance.name, instance.server_software
    end
  end
end
select_passenger_instance() click to toggle source
# File lib/phusion_passenger/config/utils.rb, line 40
def select_passenger_instance
  if name = @options[:instance]
    @instance = AdminTools::InstanceRegistry.new.find_by_name_prefix(name)
    if !@instance
      if @options[:ignore_passenger_not_running]
        message_type = "WARNING"
      else
        message_type = "ERROR"
      end
      STDERR.puts "*** #{message_type}: there doesn't seem to be a #{PROGRAM_NAME} instance running with the name '#{name}'."
      list_all_passenger_instances(AdminTools::InstanceRegistry.new.list)
      STDERR.puts
      STDERR.puts "Please pass `--instance <NAME>` to select a specific #{PROGRAM_NAME} instance."
      if @options[:ignore_passenger_not_running]
        exit
      else
        abort
      end
    elsif @instance == :ambigious
      abort "*** ERROR: there are multiple instances whose name start with '#{name}'. Please specify the full name."
    end
  else
    instances = AdminTools::InstanceRegistry.new.list
    if instances.empty?
      if @options[:ignore_passenger_not_running]
        message_type = "WARNING"
      else
        message_type = "ERROR"
      end
      STDERR.puts "*** #{message_type}: #{PROGRAM_NAME} doesn't seem to be running. If you are sure that it"
      STDERR.puts "is running, then the causes of this problem could be one of:"
      STDERR.puts
      STDERR.puts " 1. You customized the instance registry directory using Apache's"
      STDERR.puts "    PassengerInstanceRegistryDir option, Nginx's"
      STDERR.puts "    passenger_instance_registry_dir option, or #{PROGRAM_NAME} Standalone's"
      STDERR.puts "    --instance-registry-dir command line argument. If so, please set the"
      STDERR.puts "    environment variable PASSENGER_INSTANCE_REGISTRY_DIR to that directory"
      STDERR.puts "    and run this command again."
      STDERR.puts " 2. The instance directory has been removed by an operating system background"
      STDERR.puts "    service. Please set a different instance registry directory using Apache's"
      STDERR.puts "    PassengerInstanceRegistryDir option, Nginx's passenger_instance_registry_dir"
      STDERR.puts "    option, or #{PROGRAM_NAME} Standalone's --instance-registry-dir command"
      STDERR.puts "    line argument."
      if @options[:ignore_passenger_not_running]
        exit
      else
        abort
      end
    elsif instances.size == 1
      @instance = instances.first
    else
      complain_that_multiple_passenger_instances_are_running(instances)
      abort
    end
  end
end
try_performing_full_admin_basic_auth(request, instance) click to toggle source
# File lib/phusion_passenger/config/utils.rb, line 130
def try_performing_full_admin_basic_auth(request, instance)
  begin
    password = instance.full_admin_password
  rescue Errno::EACCES
    return
  end
  request.basic_auth("admin", password)
end
try_performing_ro_admin_basic_auth(request, instance) click to toggle source
# File lib/phusion_passenger/config/utils.rb, line 121
def try_performing_ro_admin_basic_auth(request, instance)
  begin
    password = instance.read_only_admin_password
  rescue Errno::EACCES
    return
  end
  request.basic_auth("ro_admin", password)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.