Represents a single application instance.
[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 Unix socket on which the application instance will accept new connections. |
[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. |
- 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/passenger/application.rb, line 44 44: def self.detect_framework_version(app_root) 45: if File.directory?("#{app_root}/vendor/rails/railties") 46: # NOTE: We must check for 'rails/railties' and not just 'rails'. 47: # Typo's vendor directory contains an empty 'rails' directory. 48: return :vendor 49: end 50: 51: environment_rb = File.read("#{app_root}/config/environment.rb") 52: environment_rb =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ 53: gem_version_spec = $1 54: if gem_version_spec.nil? 55: return nil 56: end 57: 58: found_version = Gem.cache.search('rails', gem_version_spec).map do |x| 59: x.version.version 60: end.sort.last 61: if found_version.nil? 62: # If this error was reported before, then the cache might be out of 63: # date because the Rails version may have been installed now. 64: # So we reload the RubyGems cache and try again. 65: Gem.clear_paths 66: found_version = Gem.cache.search('rails', gem_version_spec).map do |x| 67: x.version.version 68: end.sort.last 69: end 70: 71: if found_version.nil? 72: raise VersionNotFound.new("There is no Ruby on Rails version " << 73: "installed that matches version \"#{gem_version_spec}\"", 74: gem_version_spec) 75: else 76: return found_version 77: end 78: 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/passenger/application.rb, line 82 82: def initialize(app_root, pid, listen_socket_name, using_abstract_namespace, owner_pipe) 83: @app_root = app_root 84: @pid = pid 85: @listen_socket_name = listen_socket_name 86: @using_abstract_namespace = using_abstract_namespace 87: @owner_pipe = owner_pipe 88: end
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/passenger/application.rb, line 104 104: def close 105: @owner_pipe.close rescue nil 106: end
Whether listen_socket_name refers to a Unix socket in the abstract namespace. In any case, listen_socket_name does not contain the leading null byte.
Note that at the moment, only Linux seems to support abstract namespace Unix sockets.
[ show source ]
# File lib/passenger/application.rb, line 95 95: def using_abstract_namespace? 96: return @using_abstract_namespace 97: end