Represents a single application instance.
Methods
Attributes
[R] | app_root | The root directory of this application, i.e. the directory that contains ‘app/’, ‘public/’, etc. |
[R] | listen_socket_name | The name of the socket on which the application instance will accept new connections. See #listen_socket_type on how one should interpret this value. |
[R] | listen_socket_type | The type of socket that #listen_socket_name refers to. Currently this is always ‘unix’, which means that #listen_socket_name refers to the filename of a Unix domain socket. |
[R] | owner_pipe | The owner pipe of the application instance (an IO object). Please see RequestHandler for a description of the owner pipe. |
[R] | pid | The process ID of this application instance. |
Public Class methods
- Returns the Ruby on Rails version that the application requires.
- Returns :vendor if the application has a vendored Rails.
- Returns nil if the application doesn‘t specify a particular version.
Raises VersionNotFound if the required Rails version is not installed.
[ show source ]
# File lib/phusion_passenger/application.rb, line 55 55: def self.detect_framework_version(app_root) 56: if File.directory?("#{app_root}/vendor/rails/railties") 57: # NOTE: We must check for 'rails/railties' and not just 'rails'. 58: # Typo's vendor directory contains an empty 'rails' directory. 59: return :vendor 60: end 61: 62: environment_rb = File.read("#{app_root}/config/environment.rb") 63: environment_rb =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ 64: gem_version_spec = $1 65: if gem_version_spec.nil? 66: return nil 67: end 68: 69: search_results = Gem.cache.search(Gem::Dependency.new('rails', gem_version_spec), true) 70: found_version = search_results.map do |x| 71: x.version.version 72: end.sort.last 73: if found_version.nil? 74: # If this error was reported before, then the cache might be out of 75: # date because the Rails version may have been installed now. 76: # So we reload the RubyGems cache and try again. 77: Gem.clear_paths 78: search_results = Gem.cache.search(Gem::Dependency.new('rails', gem_version_spec), true) 79: found_version = search_results.map do |x| 80: x.version.version 81: end.sort.last 82: end 83: 84: if found_version.nil? 85: raise VersionNotFound.new("There is no Ruby on Rails version " << 86: "installed that matches version \"#{gem_version_spec}\"", 87: gem_version_spec) 88: else 89: return found_version 90: end 91: end
Creates a new instance of Application. The parameters correspond with the attributes of the same names. No exceptions will be thrown.
[ show source ]
# File lib/phusion_passenger/application.rb, line 95 95: def initialize(app_root, pid, listen_socket_name, listen_socket_type, owner_pipe) 96: @app_root = app_root 97: @pid = pid 98: @listen_socket_name = listen_socket_name 99: @listen_socket_type = listen_socket_type 100: @owner_pipe = owner_pipe 101: end
Public Instance methods
Close the connection with the application instance. If there are no other processes that have connections to this application instance, then it will shutdown as soon as possible.
See also AbstractRequestHandler#owner_pipe.
[ show source ]
# File lib/phusion_passenger/application.rb, line 108 108: def close 109: @owner_pipe.close rescue nil 110: end