0
@@ -6,6 +6,11 @@ require 'passenger/application_spawner'
0
require 'passenger/utils'
0
+# Raised when FrameworkSpawner or SpawnManager was unable to load a version of
0
+# the Ruby on Rails framework.
0
+class FrameworkInitError < InitializationError
0
# This class is capable of spawning Ruby on Rails application instances
0
# quickly. This is done by preloading the Ruby on Rails framework into memory,
0
# before spawning the application instances.
0
@@ -25,6 +30,10 @@ class FrameworkSpawner < AbstractServer
0
+ # This exception means that the FrameworkSpawner server process exited unexpectedly.
0
+ class Error < AbstractServer::ServerError
0
# An attribute, used internally. This should not be used outside Passenger.
0
@@ -61,8 +70,8 @@ class FrameworkSpawner < AbstractServer
0
# Overrided from AbstractServer#start.
0
# May raise these additional exceptions:
0
- # - InitializationError: The specified Ruby on Rails framework could not be loaded.
0
- # - IOError, SystemCallError, SocketError: The FrameworkSpawner server crashed.
0
+ # - FrameworkInitError: The specified Ruby on Rails framework could not be loaded.
0
+ # - FrameworkSpawner::Error: The FrameworkSpawner server exited unexpectedly.
0
@@ -77,11 +86,11 @@ class FrameworkSpawner < AbstractServer
0
message = "Could not load Ruby on Rails framework at '#{@vendor}': " <<
0
"#{child_exception.class} (#{child_exception.message})"
0
- raise
InitializationError.new(message, child_exception)
0
+ raise
FrameworkInitError.new(message, child_exception)
0
rescue IOError, SystemCallError, SocketError
0
+ raise
Error, "The framework spawner server exited unexpectedly"0
@@ -102,9 +111,9 @@ class FrameworkSpawner < AbstractServer
0
# - AbstractServer::ServerNotStarted: The FrameworkSpawner server hasn't already been started.
0
# - ArgumentError: +app_root+ doesn't appear to be a valid Ruby on Rails application root.
0
- # - InitializationError: The application raised an exception or called exit() during startup.
0
- # - IOError: The ApplicationSpawner server exited unexpectedly.
0
- # - SpawnError: The FrameworkSpawner server exited unexpectedly.
0
+ # - AppInitError: The application raised an exception or called exit() during startup.
0
+ # - ApplicationSpawner::Error: The ApplicationSpawner server exited unexpectedly.
0
+ # - FrameworkSpawner::Error: The FrameworkSpawner server exited unexpectedly.
0
def spawn_application(app_root, lower_privilege = true, lowest_user = "nobody")
0
app_root = normalize_path(app_root)
0
assert_valid_app_root(app_root)
0
@@ -116,8 +125,7 @@ class FrameworkSpawner < AbstractServer
0
raise IOError, "Connection closed"
0
if result[0] == 'exception'
0
- exception_to_propagate = unmarshal_exception(server.read_scalar)
0
- raise exception_to_propagate
0
+ raise unmarshal_exception(server.read_scalar)
0
pid, listen_socket_name, using_abstract_namespace = server.read
0
@@ -128,11 +136,7 @@ class FrameworkSpawner < AbstractServer
0
using_abstract_namespace == "true", owner_pipe)
0
rescue SystemCallError, IOError, SocketError => e
0
- if e == exception_to_propagate
0
- raise SpawnError, "The framework spawner server exited unexpectedly"
0
+ raise Error, "The framework spawner server exited unexpectedly"
0
@@ -151,7 +155,7 @@ class FrameworkSpawner < AbstractServer
0
# - ArgumentError: +app_root+ doesn't appear to be a valid Ruby on Rails
0
- # -
IOError: The FrameworkSpawner server exited unexpectedly.
0
+ # -
FrameworkSpawner::Error: The FrameworkSpawner server exited unexpectedly.
0
def reload(app_root = nil)
0
@@ -159,7 +163,7 @@ class FrameworkSpawner < AbstractServer
0
server.write("reload", normalize_path(app_root))
0
rescue SystemCallError, IOError, SocketError
0
- raise
IOError, "The framework spawner server exited unexpectedly"
0
+ raise
Error, "The framework spawner server exited unexpectedly"
0
@@ -243,7 +247,7 @@ private
0
spawner = ApplicationSpawner.new(app_root, lower_privilege, lowest_user)
0
- rescue ArgumentError,
InitializationError, IOError => e
0
+ rescue ArgumentError,
AppInitError, ApplicationSpawner::Error => e
0
client.write('exception')
0
client.write_scalar(marshal_exception(e))
0
@@ -253,7 +257,7 @@ private
0
spawner.time = Time.now
0
app = spawner.spawn_application
0
- rescue
SpawnError => e
0
+ rescue
ApplicationSpawner::Error => e
0
client.write('exception')
0
client.write_scalar(marshal_exception(e))
Comments
No one has commented yet.