Class: PhusionPassenger::Standalone::RuntimeLocator
- Defined in:
- lib/phusion_passenger/standalone/runtime_locator.rb
Overview
Helper class for locating runtime files used by Passenger Standalone.
Instance Attribute Summary collapse
-
#runtime_dir ⇒ Object
readonly
Returns the value of attribute runtime_dir.
Class Method Summary collapse
Instance Method Summary collapse
- #everything_installed? ⇒ Boolean
- #find_agents_dir ⇒ Object
- #find_lib_dir ⇒ Object
-
#find_nginx_binary ⇒ Object
Returns the path to the Nginx binary that Passenger Standalone may use, or nil if not installed.
-
#find_support_dir ⇒ Object
Returns the directory in which Passenger Standalone support binaries are stored, or nil if not installed.
-
#initialize(runtime_dir, nginx_version = PhusionPassenger::PREFERRED_NGINX_VERSION) ⇒ RuntimeLocator
constructor
A new instance of RuntimeLocator.
- #install_targets ⇒ Object
-
#nginx_binary_install_destination ⇒ Object
Returns the directory to which the Nginx binary may be installed, in case the RuntimeInstaller is to be invoked.
- #reload ⇒ Object
-
#support_dir_install_destination ⇒ Object
Returns the directory to which support binaries may be installed, in case the RuntimeInstaller is to be invoked.
Constructor Details
#initialize(runtime_dir, nginx_version = PhusionPassenger::PREFERRED_NGINX_VERSION) ⇒ RuntimeLocator
Returns a new instance of RuntimeLocator.
36 37 38 39 |
# File 'lib/phusion_passenger/standalone/runtime_locator.rb', line 36 def initialize(runtime_dir, nginx_version = PhusionPassenger::PREFERRED_NGINX_VERSION) @runtime_dir = runtime_dir || default_runtime_dir @nginx_version = nginx_version end |
Instance Attribute Details
#runtime_dir ⇒ Object (readonly)
Returns the value of attribute runtime_dir.
34 35 36 |
# File 'lib/phusion_passenger/standalone/runtime_locator.rb', line 34 def runtime_dir @runtime_dir end |
Class Method Details
.looks_like_support_dir?(dir) ⇒ Boolean
41 42 43 44 45 |
# File 'lib/phusion_passenger/standalone/runtime_locator.rb', line 41 def self.looks_like_support_dir?(dir) File.exist?("#{dir}/agents/PassengerWatchdog") && File.exist?("#{dir}/common/libboost_oxt.a") && File.exist?("#{dir}/common/libpassenger_common/ApplicationPool2/Implementation.o") end |
Instance Method Details
#everything_installed? ⇒ Boolean
108 109 110 |
# File 'lib/phusion_passenger/standalone/runtime_locator.rb', line 108 def everything_installed? return find_support_dir && find_nginx_binary end |
#find_agents_dir ⇒ Object
100 101 102 |
# File 'lib/phusion_passenger/standalone/runtime_locator.rb', line 100 def find_agents_dir return "#{find_support_dir}/agents" end |
#find_lib_dir ⇒ Object
104 105 106 |
# File 'lib/phusion_passenger/standalone/runtime_locator.rb', line 104 def find_lib_dir return find_support_dir end |
#find_nginx_binary ⇒ Object
Returns the path to the Nginx binary that Passenger Standalone may use, or nil if not installed.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/phusion_passenger/standalone/runtime_locator.rb', line 76 def find_nginx_binary return @nginx_binary if @has_nginx_binary if File.exist?(config_filename) config = PhusionPassenger::Utils::JSON.parse(File.read(config_filename)) else config = {} end if result = config["nginx_binary"] @nginx_binary = result elsif PhusionPassenger.natively_packaged? && @nginx_version == PhusionPassenger::PREFERRED_NGINX_VERSION @nginx_binary = "#{PhusionPassenger.lib_dir}/nginx" else filename = "#{@runtime_dir}/#{version}/nginx-#{@nginx_version}-#{cxx_compat_id}/nginx" if File.exist?(filename) @nginx_binary = filename else @nginx_binary = nil end end @has_nginx_binary = true return @nginx_binary end |
#find_support_dir ⇒ Object
Returns the directory in which Passenger Standalone support binaries are stored, or nil if not installed.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/phusion_passenger/standalone/runtime_locator.rb', line 53 def find_support_dir return @support_dir if @has_support_dir if PhusionPassenger.originally_packaged? if debugging? @support_dir = "#{PhusionPassenger.source_root}/buildout" else dir = "#{@runtime_dir}/#{version}/support-#{cxx_compat_id}" if self.class.looks_like_support_dir?(dir) @support_dir = dir else @support_dir = nil end end else @support_dir = PhusionPassenger.lib_dir end @has_support_dir = true return @support_dir end |
#install_targets ⇒ Object
112 113 114 115 116 117 |
# File 'lib/phusion_passenger/standalone/runtime_locator.rb', line 112 def install_targets result = [] result << :nginx if find_nginx_binary.nil? result << :support_binaries if find_support_dir.nil? return result end |
#nginx_binary_install_destination ⇒ Object
Returns the directory to which the Nginx binary may be installed, in case the RuntimeInstaller is to be invoked.
135 136 137 |
# File 'lib/phusion_passenger/standalone/runtime_locator.rb', line 135 def nginx_binary_install_destination return "#{@runtime_dir}/#{version}/nginx-#{@nginx_version}-#{cxx_compat_id}" end |
#reload ⇒ Object
47 48 49 |
# File 'lib/phusion_passenger/standalone/runtime_locator.rb', line 47 def reload @has_support_dir = @has_nginx_binary = false end |
#support_dir_install_destination ⇒ Object
Returns the directory to which support binaries may be installed, in case the RuntimeInstaller is to be invoked.
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/phusion_passenger/standalone/runtime_locator.rb', line 121 def support_dir_install_destination if PhusionPassenger.originally_packaged? if debugging? return "#{PhusionPassenger.lib_dir}/common/libpassenger_common" else return "#{@runtime_dir}/#{version}/support-#{cxx_compat_id}" end else return nil end end |