public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Refactor more stuff: move Rails-specific classes to sub-namespace.
Hongli Lai (Phusion) (author)
Fri May 09 13:35:40 -0700 2008
commit  f41228c2419a90e376de44fe4303f4b27a398fb4
tree    f5677dba5144abff8d8d3e0f2992f624e6fce888
parent  9f262d03aff2e62e4853c132b256c5171d68972d
...
30
31
32
33
34
35
36
37
38
39
40
41
 
 
 
 
42
43
44
...
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 
 
 
 
 
 
 
 
 
67
68
 
 
 
69
70
71
 
 
72
73
74
...
30
31
32
 
 
33
34
35
36
37
 
 
38
39
40
41
42
43
44
...
53
54
55
 
 
 
 
 
 
 
 
 
 
 
56
57
58
59
60
61
62
63
64
65
 
66
67
68
69
 
 
70
71
72
73
74
0
@@ -30,15 +30,15 @@ module Passenger
0
   autoload 'HTMLTemplate', 'passenger/html_template'
0
   autoload 'MessageChannel', 'passenger/message_channel'
0
   autoload 'Application', 'passenger/application'
0
- autoload 'ApplicationSpawner', 'passenger/application_spawner'
0
- autoload 'FrameworkSpawner', 'passenger/framework_spawner'
0
   autoload 'SpawnManager', 'passenger/spawn_manager'
0
   autoload 'PlatformInfo', 'passenger/platform_info'
0
   autoload 'Utils', 'passenger/utils'
0
   autoload 'NativeSupport', 'passenger/native_support'
0
   
0
- module Rails
0
- autoload 'RequestHandler', 'passenger/rails/request_handler'
0
+ module Railz
0
+ autoload 'ApplicationSpawner', 'passenger/railz/application_spawner'
0
+ autoload 'FrameworkSpawner', 'passenger/railz/framework_spawner'
0
+ autoload 'RequestHandler', 'passenger/railz/request_handler'
0
   end
0
   
0
   module Rack
0
@@ -53,22 +53,22 @@ module Passenger
0
     require 'cgi'
0
     require 'stringio'
0
     
0
- AbstractServer
0
- AbstractRequestHandler
0
- HTMLTemplate
0
- MessageChannel
0
- Application
0
- ApplicationSpawner
0
- FrameworkSpawner
0
- SpawnManager
0
- PlatformInfo
0
- Utils
0
- NativeSupport
0
+ require 'passenger/utils'
0
+ require 'passenger/native_support'
0
+ require 'passenger/abstract_server'
0
+ require 'passenger/abstract_request_handler'
0
+ require 'passenger/html_template'
0
+ require 'passenger/message_channel'
0
+ require 'passenger/application'
0
+ require 'passenger/spawn_manager'
0
+ require 'passenger/platform_info'
0
     
0
- Rails::RequestHandler
0
+ require 'passenger/railz/application_spawner'
0
+ require 'passenger/railz/framework_spawner'
0
+ require 'passenger/railz/request_handler'
0
     
0
- Rack::ApplicationSpawner
0
- Rack::RequestHandler
0
+ require 'passenger/rack/application_spawner'
0
+ require 'passenger/rack/request_handler'
0
     @@all_loaded = true
0
   end
0
 end
...
32
33
34
35
36
37
 
 
 
 
 
 
38
39
40
41
 
42
43
44
...
60
61
62
63
 
64
65
66
...
173
174
175
176
 
177
178
179
180
181
182
 
 
183
184
185
186
187
 
188
189
190
191
192
193
194
 
195
196
197
...
208
209
210
211
 
212
213
214
...
287
288
289
290
 
291
292
293
...
32
33
34
 
 
 
35
36
37
38
39
40
41
42
43
 
44
45
46
47
...
63
64
65
 
66
67
68
69
...
176
177
178
 
179
180
181
182
183
184
 
185
186
187
188
189
190
 
191
192
193
194
195
196
197
 
198
199
200
201
...
212
213
214
 
215
216
217
218
...
291
292
293
 
294
295
296
297
0
@@ -32,13 +32,16 @@ module Passenger
0
 # will preload and cache Ruby on Rails frameworks, as well as application
0
 # code, so subsequent spawns will be very fast.
0
 #
0
-# Internally, SpawnManager uses FrameworkSpawner to preload and cache
0
-# Ruby on Rails frameworks. FrameworkSpawner, in turn, uses
0
-# ApplicationSpawner to preload and cache application code.
0
+# Internally, SpawnManager uses Railz::FrameworkSpawner to preload and cache
0
+# Ruby on Rails frameworks. Railz::FrameworkSpawner, in turn, uses
0
+# Railz::ApplicationSpawner to preload and cache application code.
0
+#
0
+# In case you're wondering why the namespace is "Railz" and not "Rails":
0
+# it's to work around an obscure bug in ActiveSupport's Dispatcher.
0
 class SpawnManager < AbstractServer
0
   DEFAULT_INPUT_FD = 3
0
   FRAMEWORK_SPAWNER_MAX_IDLE_TIME = 30 * 60
0
- APP_SPAWNER_MAX_IDLE_TIME = ::Passenger::FrameworkSpawner::APP_SPAWNER_MAX_IDLE_TIME
0
+ APP_SPAWNER_MAX_IDLE_TIME = Railz::FrameworkSpawner::APP_SPAWNER_MAX_IDLE_TIME
0
   SPAWNER_CLEAN_INTERVAL = [FRAMEWORK_SPAWNER_MAX_IDLE_TIME,
0
     APP_SPAWNER_MAX_IDLE_TIME].min + 5
0
   
0
@@ -60,7 +63,7 @@ class SpawnManager < AbstractServer
0
   # Spawn a RoR application When successful, an Application object will be
0
   # returned, which represents the spawned RoR application.
0
   #
0
- # See ApplicationSpawner.new for an explanation of the +lower_privilege+,
0
+ # See Railz::ApplicationSpawner.new for an explanation of the +lower_privilege+,
0
   # +lowest_user+ and +environment+ parameters.
0
   #
0
   # The +spawn_method+ argument may be one of "smart" or "conservative".
0
@@ -173,25 +176,26 @@ private
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
+ Railz::FrameworkSpawner.new(:vendor => vendor_path)
0
         end
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
+ Railz::ApplicationSpawner.new(app_root, lower_privilege,
0
+ lowest_user, environment)
0
         end
0
       else
0
         key = "version:#{framework_version}"
0
         create_spawner = proc do
0
- FrameworkSpawner.new(:version => framework_version)
0
+ Railz::FrameworkSpawner.new(:version => framework_version)
0
         end
0
       end
0
     else
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
+ Railz::ApplicationSpawner.new(app_root, lower_privilege, lowest_user, environment)
0
       end
0
       spawner_must_be_started = false
0
     end
0
@@ -208,7 +212,7 @@ private
0
       end
0
       spawner.time = Time.now
0
       begin
0
- if spawner.is_a?(FrameworkSpawner)
0
+ if spawner.is_a?(Railz::FrameworkSpawner)
0
           return spawner.spawn_application(app_root, lower_privilege,
0
             lowest_user, environment)
0
         elsif spawner.started?
0
@@ -287,7 +291,7 @@ private
0
           current_time = Time.now
0
           @spawners.keys.each do |key|
0
             spawner = @spawners[key]
0
- if spawner.is_a?(FrameworkSpawner)
0
+ if spawner.is_a?(Railz::FrameworkSpawner)
0
               max_idle_time = FRAMEWORK_SPAWNER_MAX_IDLE_TIME
0
             else
0
               max_idle_time = APP_SPAWNER_MAX_IDLE_TIME
...
7
8
9
 
10
11
12
...
7
8
9
10
11
12
13
0
@@ -7,6 +7,7 @@ require 'spawner_privilege_lowering_spec'
0
 require 'spawner_error_handling_spec'
0
 
0
 include Passenger
0
+include Passenger::Railz
0
 
0
 describe ApplicationSpawner do
0
   include TestHelper
...
6
7
8
 
9
10
11
...
6
7
8
9
10
11
12
0
@@ -6,6 +6,7 @@ require 'spawn_server_spec'
0
 require 'spawner_privilege_lowering_spec'
0
 require 'spawner_error_handling_spec'
0
 include Passenger
0
+include Passenger::Railz
0
 
0
 # TODO: test whether FrameworkSpawner restarts ApplicationSpawner if it crashed
0
 

Comments

    No one has commented yet.