public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Search Repo:
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Use alternative means to decrease startup time. This is probably better 
than autoloading.
Hongli Lai (Phusion) (author)
Sat May 10 07:52:43 -0700 2008
commit  7520f679f9d5d68facf1edb3c9193ec384dd4622
tree    2d4d56b8c54d55e526fd68391283182de18f05e0
parent  43804b03a2f200cb2d31b46fb7ba3536e951eca6
...
15
16
17
18
19
20
21
 
 
 
22
23
24
...
28
29
30
 
 
 
 
 
 
 
 
 
 
 
31
32
33
34
35
 
36
37
38
...
15
16
17
 
 
 
 
18
19
20
21
22
23
...
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
42
43
44
45
46
47
48
0
@@ -15,10 +15,9 @@
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 'pathname'
0
-$LOAD_PATH.unshift(File.expand_path("#{File.dirname(__FILE__)}/../lib"))
0
-$LOAD_PATH.unshift(File.expand_path("#{File.dirname(__FILE__)}/../ext"))
0
-require 'passenger/spawn_manager'
0
+root = File.expand_path("#{File.dirname(__FILE__)}/..")
0
+$LOAD_PATH.unshift("#{root}/lib", "#{root}/ext")
0
+DEFAULT_INPUT_FD = 3
0
 
0
 begin
0
   STDOUT.sync = true
0
@@ -28,11 +27,22 @@ begin
0
     GC.copy_on_write_friendly = true
0
   end
0
   
0
+ input = IO.new(DEFAULT_INPUT_FD)
0
+ # Optimization for decreasing startup time. Since Apache starts the spawn
0
+ # server twice during startup, we don't want to load the Passenger classes
0
+ # if we don't need them.
0
+ # So we check whether Apache immediately closes the connection. If so,
0
+ # we exit without loading the rest of Passenger.
0
+ if input.eof?
0
+ exit
0
+ end
0
+
0
+ require 'passenger/spawn_manager'
0
   spawn_manager = Passenger::SpawnManager.new
0
- input = IO.new(Passenger::SpawnManager::DEFAULT_INPUT_FD)
0
   spawn_manager.start_synchronously(input)
0
   spawn_manager.cleanup
0
 rescue => e
0
+ require 'passenger/utils'
0
   include Passenger::Utils
0
   print_exception("spawn manager", e)
0
   exit 10
...
37
38
39
40
41
42
43
...
37
38
39
 
40
41
42
0
@@ -37,7 +37,6 @@ module Passenger
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
   SPAWNER_CLEAN_INTERVAL = [FRAMEWORK_SPAWNER_MAX_IDLE_TIME,
...
11
12
13
 
 
14
15
 
16
17
...
11
12
13
14
15
16
 
17
18
19
0
@@ -11,7 +11,9 @@ class SpawnManager
0
   end
0
 end
0
 
0
+DEFAULT_INPUT_FD = 3
0
+
0
 manager = SpawnManager.new
0
-input = IO.new(Passenger::SpawnManager::DEFAULT_INPUT_FD)
0
+input = IO.new(DEFAULT_INPUT_FD)
0
 manager.start_synchronously(input)
0
 manager.cleanup

Comments

    No one has commented yet.