Represents a single Ruby on Rails 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 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: found_version = Gem.cache.search('rails', gem_version_spec).map do |x| 70: x.version.version 71: end.sort.last 72: if found_version.nil? 73: # If this error was reported before, then the cache might be out of 74: # date because the Rails version may have been installed now. 75: # So we reload the RubyGems cache and try again. 76: Gem.clear_paths 77: found_version = Gem.cache.search('rails', gem_version_spec).map do |x| 78: x.version.version 79: end.sort.last 80: end 81: 82: if found_version.nil? 83: raise VersionNotFound.new("There is no Ruby on Rails version " << 84: "installed that matches version \"#{gem_version_spec}\"", 85: gem_version_spec) 86: else 87: return found_version 88: end 89: 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 93 93: def initialize(app_root, pid, listen_socket_name, using_abstract_namespace, owner_pipe) 94: @app_root = app_root 95: @pid = pid 96: @listen_socket_name = listen_socket_name 97: @using_abstract_namespace = using_abstract_namespace 98: @owner_pipe = owner_pipe 99: 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 RequestHandler#owner_pipe.
[ show source ]
# File lib/passenger/application.rb, line 115 115: def close 116: @owner_pipe.close rescue nil 117: 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 106 106: def using_abstract_namespace? 107: return @using_abstract_namespace 108: end