0
@@ -64,11 +64,16 @@ class SpawnManager < AbstractServer
0
# See ApplicationSpawner.new for an explanation of the +lower_privilege+,
0
# +lowest_user+ and +environment+ parameters.
0
- # SpawnManager will internally cache the code of applications, in order to
0
- # speed up future spawning attempts. This implies that, if you've
0
- # changed the application's code, you must do one of these things:
0
+ # The +spawn_method+ argument may be one of "smart" or "conservative".
0
+ # When "smart" is specified (the default), SpawnManager will internally cache the
0
+ # code of applications, in order to speed up future spawning attempts. This implies
0
+ # that, if you've changed the application's code, you must do one of these things:
0
# - Restart this SpawnManager by calling AbstractServer#stop, then AbstractServer#start.
0
# - Reload the application by calling reload with the correct app_root argument.
0
+ # Caching however can be incompatible with some applications.
0
+ # The "conservative" spawning method does not involve any caching at all.
0
+ # Spawning will be slower, but is guaranteed to be compatible with all applications.
0
# - ArgumentError: +app_root+ doesn't appear to be a valid Ruby on Rails application root.
0
@@ -77,25 +82,34 @@ class SpawnManager < AbstractServer
0
# - AbstractServer::ServerError: One of the server processes exited unexpectedly.
0
# - FrameworkInitError: The Ruby on Rails framework that the application requires could not be loaded.
0
# - AppInitError: The application raised an exception or called exit() during startup.
0
- def spawn_application(app_root, lower_privilege = true, lowest_user = "nobody", environment = "production")
0
- framework_version = Application.detect_framework_version(app_root)
0
- if framework_version == :vendor
0
- vendor_path = normalize_path("#{app_root}/vendor/rails")
0
- key = "vendor:#{vendor_path}"
0
- create_spawner = proc do
0
- FrameworkSpawner.new(:vendor => vendor_path)
0
+ def spawn_application(app_root, lower_privilege = true, lowest_user = "nobody",
0
+ environment = "production", spawn_method = "smart")
0
+ if spawn_method == "smart"
0
+ framework_version = Application.detect_framework_version(app_root)
0
+ if framework_version == :vendor
0
+ vendor_path = normalize_path("#{app_root}/vendor/rails")
0
+ key = "vendor:#{vendor_path}"
0
+ create_spawner = proc do
0
+ FrameworkSpawner.new(:vendor => vendor_path)
0
+ elsif framework_version.nil?
0
+ app_root = normalize_path(app_root)
0
+ key = "app:#{app_root}"
0
+ create_spawner = proc do
0
+ ApplicationSpawner.new(app_root, lower_privilege, lowest_user, environment)
0
+ key = "version:#{framework_version}"
0
+ create_spawner = proc do
0
+ FrameworkSpawner.new(:version => framework_version)
0
- els
if framework_version.nil?0
app_root = normalize_path(app_root)
0
key = "app:#{app_root}"
0
create_spawner = proc do
0
ApplicationSpawner.new(app_root, lower_privilege, lowest_user, environment)
0
- key = "version:#{framework_version}"
0
- create_spawner = proc do
0
- FrameworkSpawner.new(:version => framework_version)
0
@@ -111,8 +125,10 @@ class SpawnManager < AbstractServer
0
if spawner.is_a?(FrameworkSpawner)
0
return spawner.spawn_application(app_root, lower_privilege,
0
lowest_user, environment)
0
+ els
if spawn_method == "smart"0
return spawner.spawn_application
0
+ return spawner.spawn_application!
0
rescue AbstractServer::ServerError
0
@@ -176,11 +192,12 @@ class SpawnManager < AbstractServer
0
- def handle_spawn_application(app_root, lower_privilege, lowest_user, environment
)
0
+ def handle_spawn_application(app_root, lower_privilege, lowest_user, environment
, spawn_method)
0
lower_privilege = lower_privilege == "true"
0
- app = spawn_application(app_root, lower_privilege, lowest_user, environment)
0
+ app = spawn_application(app_root, lower_privilege, lowest_user,
0
+ environment, spawn_method)
0
rescue ArgumentError => e
0
send_error_page(client, 'invalid_app_root', :error => e, :app_root => app_root)
0
rescue AbstractServer::ServerError => e
Comments
No one has commented yet.