We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

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 things in favor of Rack support.
Hongli Lai (Phusion) (author)
Fri May 09 12:25:35 -0700 2008
commit  9f262d03aff2e62e4853c132b256c5171d68972d
tree    8584eac4b97a0b39f1e995467d70683b63f38527
parent  ad9d1365ddc9271244c127cd9c1dbcc462514b29
...
121
122
123
124
 
125
126
127
...
163
164
165
166
 
 
 
167
168
169
...
265
266
267
268
269
270
271
...
293
294
295
 
 
 
 
 
296
297
298
...
121
122
123
 
124
125
126
127
...
163
164
165
 
166
167
168
169
170
171
...
267
268
269
 
270
271
272
...
294
295
296
297
298
299
300
301
302
303
304
0
@@ -121,7 +121,7 @@ class AbstractRequestHandler
0
   # Create a new RequestHandler with the given owner pipe.
0
   # +owner_pipe+ must be the readable part of a pipe IO object.
0
   def initialize(owner_pipe)
0
- if ENV['PASSENGER_NO_ABSTRACT_NAMESPACE_SOCKETS'].blank?
0
+ if abstract_namespace_sockets_allowed?
0
       @using_abstract_namespace = create_unix_socket_on_abstract_namespace
0
     else
0
       @using_abstract_namespace = false
0
@@ -163,7 +163,9 @@ class AbstractRequestHandler
0
         end
0
         begin
0
           headers, input = parse_request(client)
0
- process_request(headers, input, client)
0
+ if headers
0
+ process_request(headers, input, client)
0
+ end
0
         rescue IOError, SocketError, SystemCallError => e
0
           print_exception("Passenger RequestHandler", e)
0
         ensure
0
@@ -265,7 +267,6 @@ private
0
     channel = MessageChannel.new(socket)
0
     headers_data = channel.read_scalar(MAX_HEADER_SIZE)
0
     if headers_data.nil?
0
- socket.close
0
       return
0
     end
0
     headers = Hash[*headers_data.split("\0")]
0
@@ -293,6 +294,11 @@ private
0
     end
0
     return data
0
   end
0
+
0
+ def abstract_namespace_sockets_allowed?
0
+ return !ENV['PASSENGER_NO_ABSTRACT_NAMESPACE_SOCKETS'] ||
0
+ ENV['PASSENGER_NO_ABSTRACT_NAMESPACE_SOCKETS'].empty?
0
+ end
0
 end
0
 
0
 end # module Passenger
...
253
254
255
 
256
257
258
...
253
254
255
256
257
258
259
0
@@ -253,6 +253,7 @@ private
0
     status = args[0]
0
     if status == 'exception'
0
       child_exception = unmarshal_exception(channel.read_scalar)
0
+ #print_exception(self.class.to_s, child_exception)
0
       raise AppInitError.new(
0
         "Application '#{@app_root}' raised an exception: " <<
0
         "#{child_exception.class} (#{child_exception.message})",
...
14
15
16
17
18
19
20
...
14
15
16
 
17
18
19
0
@@ -14,7 +14,6 @@
0
 # with this program; if not, write to the Free Software Foundation, Inc.,
0
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
0
 
0
-require 'rubygems'
0
 require 'passenger/passenger'
0
 module Passenger
0
 
...
17
18
19
 
 
 
 
 
 
 
20
21
22
23
24
25
26
27
28
29
30
31
32
...
41
42
43
44
45
46
47
48
49
50
51
52
53
 
 
 
54
55
56
57
58
59
60
61
...
68
69
70
71
72
73
74
75
76
77
78
79
...
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
32
33
34
 
35
36
37
...
46
47
48
 
 
 
 
 
 
49
50
51
52
53
54
55
56
57
58
59
 
60
61
62
...
69
70
71
 
 
 
 
 
 
72
73
74
0
@@ -17,16 +17,21 @@
0
 module Passenger
0
   ROOT = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
0
   $LOAD_PATH.unshift("#{ROOT}/ext")
0
+
0
+ # We can't autoload the exception classes because their class names
0
+ # don't match their filenames, and that'll trigger bugs in
0
+ # ActiveSupport's Dependency autoloading code.
0
+ require 'passenger/exceptions'
0
+ # And for some reason, CGIFixed conflicts too.
0
+ require 'passenger/cgi_fixed'
0
 
0
   autoload 'AbstractServer', 'passenger/abstract_server'
0
   autoload 'AbstractRequestHandler', 'passenger/abstract_request_handler'
0
   autoload 'HTMLTemplate', 'passenger/html_template'
0
   autoload 'MessageChannel', 'passenger/message_channel'
0
- autoload 'CGIFixed', 'passenger/cgi_fixed'
0
   autoload 'Application', 'passenger/application'
0
   autoload 'ApplicationSpawner', 'passenger/application_spawner'
0
   autoload 'FrameworkSpawner', 'passenger/framework_spawner'
0
- autoload 'RackSpawner', 'passenger/rack_spawner'
0
   autoload 'SpawnManager', 'passenger/spawn_manager'
0
   autoload 'PlatformInfo', 'passenger/platform_info'
0
   autoload 'Utils', 'passenger/utils'
0
@@ -41,21 +46,17 @@ module Passenger
0
     autoload 'RequestHandler', 'passenger/rack/request_handler'
0
   end
0
   
0
- autoload 'VersionNotFound', 'passenger/exceptions'
0
- autoload 'AppInitError', 'passenger/exceptions'
0
- autoload 'InitializationError', 'passenger/exceptions'
0
- autoload 'FrameworkInitError', 'passenger/exceptions'
0
- autoload 'UnknownError', 'passenger/exceptions'
0
-
0
   @@all_loaded = false
0
   
0
   def self.load_all_classes!
0
     return if @@all_loaded
0
+ require 'cgi'
0
+ require 'stringio'
0
+
0
     AbstractServer
0
     AbstractRequestHandler
0
     HTMLTemplate
0
     MessageChannel
0
- CGIFixed
0
     Application
0
     ApplicationSpawner
0
     FrameworkSpawner
0
@@ -68,12 +69,6 @@ module Passenger
0
     
0
     Rack::ApplicationSpawner
0
     Rack::RequestHandler
0
-
0
- VersionNotFound
0
- AppInitError
0
- InitializationError
0
- FrameworkInitError
0
- UnknownError
0
     @@all_loaded = true
0
   end
0
 end
...
17
18
19
20
 
 
 
 
 
 
 
 
 
 
 
21
22
23
...
25
26
27
28
29
30
31
32
33
34
35
36
 
37
38
39
...
17
18
19
 
20
21
22
23
24
25
26
27
28
29
30
31
32
33
...
35
36
37
 
 
 
 
 
38
39
40
 
41
42
43
44
0
@@ -17,7 +17,17 @@
0
 require 'passenger/passenger'
0
 module Passenger
0
 
0
-# This class is capable of spawning Ruby on Rails application instances.
0
+# The spawn manager is capable of spawning Ruby on Rails or Rack application
0
+# instances. It acts like a simple fascade for the rest of the spawn manager
0
+# system.
0
+#
0
+# *Note*: SpawnManager may only be started synchronously with
0
+# AbstractServer#start_synchronously. Starting asynchronously has not been
0
+# tested. Don't forget to call cleanup after the server's main loop has
0
+# finished.
0
+#
0
+# == Ruby on Rails optimizations ===
0
+#
0
 # Spawning a Ruby on Rails application is usually slow. But SpawnManager
0
 # will preload and cache Ruby on Rails frameworks, as well as application
0
 # code, so subsequent spawns will be very fast.
0
@@ -25,15 +35,10 @@ module Passenger
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
-#
0
-# *Note*: SpawnManager may only be started synchronously with
0
-# AbstractServer#start_synchronously. Starting asynchronously has not been
0
-# tested. Don't forget to call cleanup after the server's main loop has
0
-# finished.
0
 class SpawnManager < AbstractServer
0
   DEFAULT_INPUT_FD = 3
0
   FRAMEWORK_SPAWNER_MAX_IDLE_TIME = 30 * 60
0
- APP_SPAWNER_MAX_IDLE_TIME = FrameworkSpawner::APP_SPAWNER_MAX_IDLE_TIME
0
+ APP_SPAWNER_MAX_IDLE_TIME = ::Passenger::FrameworkSpawner::APP_SPAWNER_MAX_IDLE_TIME
0
   SPAWNER_CLEAN_INTERVAL = [FRAMEWORK_SPAWNER_MAX_IDLE_TIME,
0
     APP_SPAWNER_MAX_IDLE_TIME].min + 5
0
   

Comments

    No one has commented yet.