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
detect_framework_version(app_root)
  • 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.

    # File lib/phusion_passenger/application.rb, line 50
50:         def self.detect_framework_version(app_root)
51:                 if File.directory?("#{app_root}/vendor/rails/railties")
52:                         # NOTE: We must check for 'rails/railties' and not just 'rails'.
53:                         # Typo's vendor directory contains an empty 'rails' directory.
54:                         return :vendor
55:                 end
56:                 
57:                 environment_rb = File.read("#{app_root}/config/environment.rb")
58:                 environment_rb =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
59:                 gem_version_spec = $1
60:                 if gem_version_spec.nil?
61:                         return nil
62:                 end
63:                 
64:                 search_results = Gem.cache.search(Gem::Dependency.new('rails', gem_version_spec), true)
65:                 found_version = search_results.map do |x|
66:                         x.version.version
67:                 end.sort.last
68:                 if found_version.nil?
69:                         # If this error was reported before, then the cache might be out of
70:                         # date because the Rails version may have been installed now.
71:                         # So we reload the RubyGems cache and try again.
72:                         Gem.clear_paths
73:                         search_results = Gem.cache.search(Gem::Dependency.new('rails', gem_version_spec), true)
74:                         found_version = search_results.map do |x|
75:                                 x.version.version
76:                         end.sort.last
77:                 end
78:                 
79:                 if found_version.nil?
80:                         raise VersionNotFound.new("There is no Ruby on Rails version " <<
81:                                 "installed that matches version \"#{gem_version_spec}\"",
82:                                 gem_version_spec)
83:                 else
84:                         return found_version
85:                 end
86:         end
new(app_root, pid, listen_socket_name, listen_socket_type, owner_pipe)

Creates a new instance of Application. The parameters correspond with the attributes of the same names. No exceptions will be thrown.

    # File lib/phusion_passenger/application.rb, line 90
90:         def initialize(app_root, pid, listen_socket_name, listen_socket_type, owner_pipe)
91:                 @app_root = app_root
92:                 @pid = pid
93:                 @listen_socket_name = listen_socket_name
94:                 @listen_socket_type = listen_socket_type
95:                 @owner_pipe = owner_pipe
96:         end
Public Instance methods
close()

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.

     # File lib/phusion_passenger/application.rb, line 103
103:         def close
104:                 @owner_pipe.close rescue nil
105:         end