module PhusionPassenger

Phusion Passenger - www.phusionpassenger.com/ Copyright © 2010-2015 Phusion

“Phusion Passenger” is a trademark of Hongli Lai & Ninh Bui.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

IMPORTANT: do not directly or indirectly require native_support; we can't compile it yet until we have a compiler, and installers usually check whether a compiler is installed.

Phusion Passenger - www.phusionpassenger.com/ Copyright © 2010-2014 Phusion

“Phusion Passenger” is a trademark of Hongli Lai & Ninh Bui.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Phusion Passenger - www.phusionpassenger.com/ Copyright © 2010-2013 Phusion

“Phusion Passenger” is a trademark of Hongli Lai & Ninh Bui.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Phusion Passenger - www.phusionpassenger.com/ Copyright © 2010-2015 Phusion

“Phusion Passenger” is a trademark of Hongli Lai & Ninh Bui.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Phusion Passenger - www.phusionpassenger.com/ Copyright © 2010-2015 Phusion

“Phusion Passenger” is a trademark of Hongli Lai & Ninh Bui.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Phusion Passenger - www.phusionpassenger.com/ Copyright © 2010-2015 Phusion

“Phusion Passenger” is a trademark of Hongli Lai & Ninh Bui.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Phusion Passenger - www.phusionpassenger.com/ Copyright © 2010-2015 Phusion

“Phusion Passenger” is a trademark of Hongli Lai & Ninh Bui.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Phusion Passenger - www.phusionpassenger.com/ Copyright © 2010-2015 Phusion

“Phusion Passenger” is a trademark of Hongli Lai & Ninh Bui.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Phusion Passenger - www.phusionpassenger.com/ Copyright © 2010-2015 Phusion

“Phusion Passenger” is a trademark of Hongli Lai & Ninh Bui.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

## Coding notes

### Lazy library loading

We lazy load as many libraries as possible not only to improve startup performance, but also to ensure that we don't require libraries before we've passed the dependency checking stage of the runtime installer.

### Path handling

Handle paths as follows so that the behavior complies with the documentation:

Phusion Passenger - www.phusionpassenger.com/ Copyright © 2010-2015 Phusion

“Phusion Passenger” is a trademark of Hongli Lai & Ninh Bui.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Phusion Passenger - www.phusionpassenger.com/ Copyright © 2010-2014 Phusion

“Phusion Passenger” is a trademark of Hongli Lai & Ninh Bui.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Phusion Passenger - www.phusionpassenger.com/ Copyright © 2014 Phusion

“Phusion Passenger” is a trademark of Hongli Lai & Ninh Bui.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Phusion Passenger - www.phusionpassenger.com/ Copyright © 2013 Phusion

“Phusion Passenger” is a trademark of Hongli Lai & Ninh Bui.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

daemon_controller, library for robust daemon management Copyright © 2010-2015 Phusion

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Constants

APACHE2_MODULE_CONF_NAME

The name for the /etc/apache2/mods-available/*.{load,conf} file.

FILE_LOCATION
GLOBAL_NAMESPACE_DIRNAME_

Directories ######

LVL_CRIT
LVL_DEBUG
LVL_DEBUG2
LVL_DEBUG3
LVL_ERROR
LVL_INFO
LVL_NOTICE
LVL_WARN
NGINX_SHA256_CHECKSUM
OPTIONAL_LOCATIONS_INI_FIELDS
PACKAGE_NAME

Names and version numbers ######

PASSENGER_APP_GROUP_NAME
PASSENGER_TXN_ID
PCRE_SHA256_CHECKSUM
PLUGIN_DIRS

Directories in which to look for plugins.

PREFERRED_NGINX_VERSION
PREFERRED_PCRE_VERSION
RACK_HIJACK_IO
REQUIRED_LOCATIONS_INI_FIELDS
STANDALONE_INTERFACE_VERSION
USER_NAMESPACE_DIRNAME_

Subdirectory under $HOME to use for storing stuff.

VERSION_STRING

Run 'rake src/cxx_supportlib/Constants.h' after changing this number.

Public Class Methods

binaries_sites() click to toggle source

Other resource locations ######

# File src/ruby_supportlib/phusion_passenger.rb, line 212
def self.binaries_sites
  return [
    { :url => "https://oss-binaries.phusionpassenger.com/binaries/passenger/by_release".freeze,
      :cacert => "#{resources_dir}/oss-binaries.phusionpassenger.com.crt".freeze },
    { :url => "https://s3.amazonaws.com/phusion-passenger/binaries/passenger/by_release".freeze }
  ]
end
custom_packaged?() click to toggle source
# File src/ruby_supportlib/phusion_passenger.rb, line 143
def self.custom_packaged?
  return @custom_packaged
end
find_support_binary(name) click to toggle source
# File src/ruby_supportlib/phusion_passenger.rb, line 195
def self.find_support_binary(name)
  all_support_binary_dirs = [
    support_binaries_dir,
    user_support_binaries_dir
  ]
  all_support_binary_dirs.each do |dir|
    result = "#{dir}/#{name}"
    if File.exist?(result)
      return result
    end
  end
  return nil
end
install_spec() click to toggle source

The installation specification string, as passed to locate_directories.

# File src/ruby_supportlib/phusion_passenger.rb, line 176
def self.install_spec
  return @install_spec
end
installed_from_release_package?() click to toggle source

Whether the current Phusion Passenger installation is installed from a release package, e.g. an official gem or official tarball. Retruns false if e.g. the gem was built by the user, or if this install is from a git repository.

# File src/ruby_supportlib/phusion_passenger.rb, line 171
def self.installed_from_release_package?
  File.exist?("#{resources_dir}/release.txt")
end
locate_directories(install_spec = nil) click to toggle source

Follows the logic of src/cxx_supportlib/ResourceLocator.h, so don't forget to modify that too.

# File src/ruby_supportlib/phusion_passenger.rb, line 93
def self.locate_directories(install_spec = nil)
  @install_spec = install_spec || infer_install_spec
  if @install_spec && File.file?(@install_spec)
    filename = @install_spec
    options  = parse_ini_file(filename)

    @custom_packaged = true
    @packaging_method = get_option(filename, options, 'packaging_method')
    REQUIRED_LOCATIONS_INI_FIELDS.each do |field|
      value = get_option(filename, options, field.to_s)
      value.freeze unless value.nil?
      instance_variable_set("@#{field}", value)
    end
    OPTIONAL_LOCATIONS_INI_FIELDS.each do |field|
      value = get_option(filename, options, field.to_s, false)
      value.freeze unless value.nil?
      instance_variable_set("@#{field}", value)
    end
  else
    source_root            = File.dirname(File.dirname(File.dirname(FILE_LOCATION)))
    @install_spec          = source_root
    @custom_packaged       = false
    @bin_dir               = "#{source_root}/bin".freeze
    @support_binaries_dir  = "#{source_root}/buildout/support-binaries".freeze
    @lib_dir               = "#{source_root}/buildout".freeze
    @helper_scripts_dir    = "#{source_root}/src/helper-scripts".freeze
    @resources_dir         = "#{source_root}/resources".freeze
    @include_dir           = "#{source_root}/src".freeze
    @doc_dir               = "#{source_root}/doc".freeze
    @ruby_libdir           = File.dirname(FILE_LOCATION).freeze
    @node_libdir           = "#{source_root}/src/nodejs_supportlib".freeze
    @apache2_module_path   = "#{source_root}/buildout/apache2/mod_passenger.so".freeze
    @ruby_extension_source_dir = "#{source_root}/src/ruby_native_extension".freeze
    @nginx_module_source_dir   = "#{source_root}/src/nginx_module".freeze
    @download_cache_dir        = "#{source_root}/download_cache".freeze
    @build_system_dir          = source_root.dup.freeze
    REQUIRED_LOCATIONS_INI_FIELDS.each do |field|
      if instance_variable_get("@#{field}").nil?
        raise "BUG: @#{field} not set"
      end
    end
  end
end
originally_packaged?() click to toggle source

Returns whether this Phusion Passenger installation is in the 'originally packaged' configuration (as opposed to the 'custom packaged' configuration.

# File src/ruby_supportlib/phusion_passenger.rb, line 139
def self.originally_packaged?
  return !@custom_packaged
end
packaging_method() click to toggle source

If Phusion Passenger is custom packaged, returns which packaging method was used. Can be 'deb', 'rpm', 'homebrew', 'test' or 'unknown'.

# File src/ruby_supportlib/phusion_passenger.rb, line 150
def self.packaging_method
  return @packaging_method
end
packaging_method_description() click to toggle source
# File src/ruby_supportlib/phusion_passenger.rb, line 154
def self.packaging_method_description
  case packaging_method
  when "deb"
    "Debian packages"
  when "rpm"
    "RPM packages"
  when "homebrew"
    "Homebrew"
  else
    "gem or tarball"
  end
end
require_passenger_lib(name) click to toggle source

Instead of calling `require 'phusion_passenger/foo'`, you should call `PhusionPassenger.require_passenger_lib 'foo'`. This is because when Phusion Passenger is natively packaged, it may still be run with arbitrary Ruby interpreters. Adding ruby_libdir to $LOAD_PATH is then dangerous because ruby_libdir may be the distribution's Ruby's vendor_ruby directory, which may be incompatible with the active Ruby interpreter. This method looks up the exact filename directly.

Using this method also has two more advantages:

1. It is immune to Bundler's load path mangling code.
2. It is faster than plan require() because it doesn't need to
   scan the entire load path.
# File src/ruby_supportlib/phusion_passenger.rb, line 233
def self.require_passenger_lib(name)
  require("#{ruby_libdir}/phusion_passenger/#{name}")
end
user_support_binaries_dir() click to toggle source
# File src/ruby_supportlib/phusion_passenger.rb, line 191
def self.user_support_binaries_dir
  return "#{home_dir}/#{USER_NAMESPACE_DIRNAME_}/support-binaries/#{VERSION_STRING}"
end

Private Class Methods

get_bool_option(filename, options, key) click to toggle source
# File src/ruby_supportlib/phusion_passenger.rb, line 294
def self.get_bool_option(filename, options, key)
  value = get_option(filename, options, key)
  return value == 'yes' || value == 'true' || value == 'on' || value == '1'
end
get_option(filename, options, key, required = true) click to toggle source
# File src/ruby_supportlib/phusion_passenger.rb, line 283
def self.get_option(filename, options, key, required = true)
  value = options[key]
  if value
    return value
  elsif required
    raise "Option '#{key}' missing in file '#{filename}'"
  else
    return nil
  end
end
home_dir(respect_home_env = false) click to toggle source

The HOME environment variable is often unreliable, because for example `sudo` preserves it. That's why we don't respect it by default.

# File src/ruby_supportlib/phusion_passenger.rb, line 302
def self.home_dir(respect_home_env = false)
  if respect_home_env
    home = ENV['HOME'].to_s
  end
  if home.nil? || home.empty?
    require 'etc' if !defined?(Etc)
    home = Etc.getpwuid(Process.uid).dir
  end
  return home
end
infer_install_spec() click to toggle source
# File src/ruby_supportlib/phusion_passenger.rb, line 239
def self.infer_install_spec
  filename = ENV['PASSENGER_LOCATION_CONFIGURATION_FILE']
  return filename if filename && !filename.empty?

  filename = File.dirname(FILE_LOCATION) + "/phusion_passenger/locations.ini"
  return filename if filename && File.exist?(filename)

  require 'etc' if !defined?(Etc)
  begin
    home_dir = Etc.getpwuid(Process.uid).dir
  rescue ArgumentError
    # Unknown user.
    home_dir = ENV['HOME']
  end
  if home_dir && !home_dir.empty?
    filename = "#{home_dir}/#{USER_NAMESPACE_DIRNAME_}/locations.ini"
    return filename if File.exist?(filename)
  end

  filename = "/etc/#{GLOBAL_NAMESPACE_DIRNAME_}/locations.ini"
  return filename if File.exist?(filename)

  return nil
end
parse_ini_file(filename) click to toggle source
# File src/ruby_supportlib/phusion_passenger.rb, line 264
def self.parse_ini_file(filename)
  options  = {}
  in_locations_section = false
  File.open(filename, 'r') do |f|
    while !f.eof?
      line = f.readline
      line.strip!
      next if line.empty?
      if line =~ /\A\[(.+)\]\Z/
        in_locations_section = $1 == 'locations'
      elsif in_locations_section && line =~ /=/
        key, value = line.split(/ *= */, 2)
        options[key.freeze] = value.freeze
      end
    end
  end
  return options
end

Public Instance Methods

advertised_concurrency_level() click to toggle source
# File src/ruby_supportlib/phusion_passenger/public_api.rb, line 57
def advertised_concurrency_level
  @@advertised_concurrency_level
end
advertised_concurrency_level=(value) click to toggle source
# File src/ruby_supportlib/phusion_passenger/public_api.rb, line 61
def advertised_concurrency_level=(value)
  @@advertised_concurrency_level = value
end
call_event(name, *args) click to toggle source
# File src/ruby_supportlib/phusion_passenger/public_api.rb, line 39
def call_event(name, *args)
  callback_list_for_event(name).each do |callback|
    callback.call(*args)
  end
end
install_framework_extensions!(user_options = {}) click to toggle source

For backward compatibility

# File src/ruby_supportlib/phusion_passenger/public_api.rb, line 46
def install_framework_extensions!(user_options = {})
  if PhusionPassenger::App.options["analytics"]
    config = PhusionPassenger::App.options.merge(UnionStationHooks.config)
    user_options.each_pair do |key, value|
      config[key.to_s] = value
    end
    UnionStationHooks.config.update(config)
    UnionStationHooks.initialize!
  end
end
on_event(name, &block) click to toggle source
# File src/ruby_supportlib/phusion_passenger/public_api.rb, line 35
def on_event(name, &block)
  callback_list_for_event(name) << block
end
union_station_key() click to toggle source
# File src/ruby_supportlib/phusion_passenger/public_api.rb, line 65
def union_station_key
  @@union_station_key
end
union_station_key=(value) click to toggle source
# File src/ruby_supportlib/phusion_passenger/public_api.rb, line 69
def union_station_key=(value)
  @@union_station_key = value
end

Private Instance Methods

callback_list_for_event(name) click to toggle source
# File src/ruby_supportlib/phusion_passenger/public_api.rb, line 74
def callback_list_for_event(name)
  return case name
  when :starting_worker_process
    @@event_starting_worker_process
  when :stopping_worker_process
    @@event_stopping_worker_process
  when :starting_request_handler_thread
    @@event_starting_request_handler_thread
  when :credentials
    @@event_credentials
  when :after_installing_signal_handlers
    @@event_after_installing_signal_handlers
  when :oob_work
    @@event_oob_work
  else
    raise ArgumentError, "Unknown event name '#{name}'"
  end
end