Class: PhusionPassenger::Application
- Defined in:
- lib/phusion_passenger/application.rb
Overview
Represents a single application instance.
Instance Attribute Summary collapse
-
#app_root ⇒ Object
readonly
The root directory of this application, i.e.
-
#listen_socket_name ⇒ Object
readonly
The name of the socket on which the application instance will accept new connections.
-
#listen_socket_type ⇒ Object
readonly
The type of socket that #listen_socket_name refers to.
-
#owner_pipe ⇒ Object
readonly
The owner pipe of the application instance (an IO object).
-
#pid ⇒ Object
readonly
The process ID of this application instance.
Class Method Summary collapse
-
.detect_framework_version(app_root) ⇒ Object
-
Returns the Ruby on Rails version that the application requires.
-
Instance Method Summary collapse
-
#close ⇒ Object
Close the connection with the application instance.
-
#initialize(app_root, pid, listen_socket_name, listen_socket_type, owner_pipe) ⇒ Application
constructor
Creates a new instance of Application.
Constructor Details
#initialize(app_root, pid, listen_socket_name, listen_socket_type, owner_pipe) ⇒ Application
Creates a new instance of Application. The parameters correspond with the attributes of the same names. No exceptions will be thrown.
95 96 97 98 99 100 101 |
# File 'lib/phusion_passenger/application.rb', line 95 def initialize(app_root, pid, listen_socket_name, listen_socket_type, owner_pipe) @app_root = app_root @pid = pid @listen_socket_name = listen_socket_name @listen_socket_type = listen_socket_type @owner_pipe = owner_pipe end |
Instance Attribute Details
#app_root ⇒ Object (readonly)
The root directory of this application, i.e. the directory that contains ‘app/’, ‘public/’, etc.
32 33 34 |
# File 'lib/phusion_passenger/application.rb', line 32 def app_root @app_root end |
#listen_socket_name ⇒ Object (readonly)
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.
40 41 42 |
# File 'lib/phusion_passenger/application.rb', line 40 def listen_socket_name @listen_socket_name end |
#listen_socket_type ⇒ Object (readonly)
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.
45 46 47 |
# File 'lib/phusion_passenger/application.rb', line 45 def listen_socket_type @listen_socket_type end |
#owner_pipe ⇒ Object (readonly)
The owner pipe of the application instance (an IO object). Please see RequestHandler for a description of the owner pipe.
49 50 51 |
# File 'lib/phusion_passenger/application.rb', line 49 def owner_pipe @owner_pipe end |
#pid ⇒ Object (readonly)
The process ID of this application instance.
35 36 37 |
# File 'lib/phusion_passenger/application.rb', line 35 def pid @pid end |
Class Method Details
.detect_framework_version(app_root) ⇒ Object
-
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.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/phusion_passenger/application.rb', line 55 def self.detect_framework_version(app_root) if File.directory?("#{app_root}/vendor/rails/railties") # NOTE: We must check for 'rails/railties' and not just 'rails'. # Typo's vendor directory contains an empty 'rails' directory. return :vendor end environment_rb = File.read("#{app_root}/config/environment.rb") environment_rb =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ gem_version_spec = $1 if gem_version_spec.nil? return nil end search_results = Gem.cache.search(Gem::Dependency.new('rails', gem_version_spec), true) found_version = search_results.map do |x| x.version.version end.sort.last if found_version.nil? # If this error was reported before, then the cache might be out of # date because the Rails version may have been installed now. # So we reload the RubyGems cache and try again. Gem.clear_paths search_results = Gem.cache.search(Gem::Dependency.new('rails', gem_version_spec), true) found_version = search_results.map do |x| x.version.version end.sort.last end if found_version.nil? raise VersionNotFound.new("There is no Ruby on Rails version " << "installed that matches version \"#{gem_version_spec}\"", gem_version_spec) else return found_version end end |
Instance Method Details
#close ⇒ Object
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.
108 109 110 |
# File 'lib/phusion_passenger/application.rb', line 108 def close @owner_pipe.close rescue nil end |