mongrel 0.3.11 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -2
- data/bin/mongrel_rails +65 -101
- data/bin/mongrel_rails_service +1 -1
- data/bin/mongrel_rails_svc +131 -115
- data/doc/rdoc/classes/Class.html +197 -0
- data/doc/rdoc/classes/Class.src/M000001.html +24 -0
- data/doc/rdoc/classes/Class.src/M000002.html +62 -0
- data/doc/rdoc/classes/Class.src/M000003.html +21 -0
- data/doc/rdoc/classes/Class.src/M000004.html +20 -0
- data/doc/rdoc/classes/IO.html +170 -0
- data/doc/rdoc/classes/IO.src/M000005.html +19 -0
- data/doc/rdoc/classes/IO.src/M000006.html +19 -0
- data/doc/rdoc/classes/Kernel.html +159 -0
- data/doc/rdoc/classes/Kernel.src/M000025.html +19 -0
- data/doc/rdoc/classes/Kernel.src/M000026.html +25 -0
- data/doc/rdoc/classes/Mongrel.html +181 -0
- data/doc/rdoc/classes/Mongrel/CGIWrapper.html +383 -0
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000090.html +24 -0
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000091.html +47 -0
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000092.html +34 -0
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000093.html +27 -0
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000094.html +25 -0
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000095.html +18 -0
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000096.html +18 -0
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000097.html +18 -0
- data/doc/rdoc/classes/Mongrel/CGIWrapper.src/M000098.html +19 -0
- data/doc/rdoc/classes/Mongrel/Camping.html +177 -0
- data/doc/rdoc/classes/Mongrel/Camping.src/M000048.html +22 -0
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.html +165 -0
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000049.html +18 -0
- data/doc/rdoc/classes/Mongrel/Camping/CampingHandler.src/M000050.html +27 -0
- data/doc/rdoc/classes/Mongrel/Command.html +119 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.html +337 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000029.html +24 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000030.html +41 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000031.html +18 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000032.html +18 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000033.html +18 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000034.html +22 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000035.html +18 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000036.html +18 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000037.html +18 -0
- data/doc/rdoc/classes/Mongrel/Command/Base.src/M000038.html +18 -0
- data/doc/rdoc/classes/Mongrel/Command/Registry.html +192 -0
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000039.html +20 -0
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000040.html +25 -0
- data/doc/rdoc/classes/Mongrel/Command/Registry.src/M000041.html +46 -0
- data/doc/rdoc/classes/Mongrel/Configurator.html +563 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000099.html +24 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000100.html +23 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000101.html +18 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000102.html +32 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000103.html +19 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000104.html +31 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000105.html +33 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000106.html +18 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000107.html +25 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000108.html +19 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000109.html +22 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000110.html +21 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000111.html +18 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000112.html +27 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000113.html +46 -0
- data/doc/rdoc/classes/Mongrel/Configurator.src/M000114.html +18 -0
- data/doc/rdoc/classes/Mongrel/Const.html +286 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.html +288 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000058.html +20 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000059.html +42 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000060.html +40 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000061.html +51 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000062.html +40 -0
- data/doc/rdoc/classes/Mongrel/DirHandler.src/M000063.html +18 -0
- data/doc/rdoc/classes/Mongrel/Error404Handler.html +171 -0
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000115.html +18 -0
- data/doc/rdoc/classes/Mongrel/Error404Handler.src/M000116.html +18 -0
- data/doc/rdoc/classes/Mongrel/HeaderOut.html +185 -0
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000072.html +18 -0
- data/doc/rdoc/classes/Mongrel/HeaderOut.src/M000073.html +18 -0
- data/doc/rdoc/classes/Mongrel/HttpHandler.html +152 -0
- data/doc/rdoc/classes/Mongrel/HttpHandler.src/M000074.html +17 -0
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.html +169 -0
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000027.html +18 -0
- data/doc/rdoc/classes/Mongrel/HttpHandlerPlugin.src/M000028.html +17 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.html +271 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000051.html +28 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000052.html +29 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000053.html +29 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000054.html +41 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000055.html +27 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000056.html +27 -0
- data/doc/rdoc/classes/Mongrel/HttpParser.src/M000057.html +28 -0
- data/doc/rdoc/classes/Mongrel/HttpRequest.html +222 -0
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000117.html +28 -0
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000118.html +20 -0
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000119.html +20 -0
- data/doc/rdoc/classes/Mongrel/HttpRequest.src/M000120.html +32 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.html +371 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000075.html +26 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000076.html +20 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000077.html +25 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000078.html +22 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000079.html +22 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000080.html +23 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000081.html +18 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000082.html +20 -0
- data/doc/rdoc/classes/Mongrel/HttpResponse.src/M000083.html +18 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.html +360 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000064.html +24 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000065.html +65 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000066.html +24 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000067.html +60 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000068.html +28 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000069.html +18 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000070.html +22 -0
- data/doc/rdoc/classes/Mongrel/HttpServer.src/M000071.html +18 -0
- data/doc/rdoc/classes/Mongrel/Rails.html +112 -0
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.html +223 -0
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000042.html +35 -0
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000043.html +25 -0
- data/doc/rdoc/classes/Mongrel/Rails/RailsConfigurator.src/M000044.html +32 -0
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.html +250 -0
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000045.html +22 -0
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000046.html +48 -0
- data/doc/rdoc/classes/Mongrel/Rails/RailsHandler.src/M000047.html +23 -0
- data/doc/rdoc/classes/Mongrel/StopServer.html +117 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.html +301 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000084.html +18 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000085.html +18 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000086.html +39 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000087.html +51 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000088.html +36 -0
- data/doc/rdoc/classes/Mongrel/URIClassifier.src/M000089.html +83 -0
- data/doc/rdoc/classes/MongrelDbg.html +209 -0
- data/doc/rdoc/classes/MongrelDbg.src/M000020.html +19 -0
- data/doc/rdoc/classes/MongrelDbg.src/M000021.html +20 -0
- data/doc/rdoc/classes/MongrelDbg.src/M000022.html +22 -0
- data/doc/rdoc/classes/MongrelDbg.src/M000023.html +21 -0
- data/doc/rdoc/classes/MongrelDbg.src/M000024.html +18 -0
- data/doc/rdoc/classes/ObjectTracker.html +176 -0
- data/doc/rdoc/classes/ObjectTracker.src/M000016.html +22 -0
- data/doc/rdoc/classes/ObjectTracker.src/M000017.html +18 -0
- data/doc/rdoc/classes/ObjectTracker.src/M000018.html +18 -0
- data/doc/rdoc/classes/ObjectTracker.src/M000019.html +46 -0
- data/doc/rdoc/classes/RequestLog.html +113 -0
- data/doc/rdoc/classes/RequestLog/Files.html +144 -0
- data/doc/rdoc/classes/RequestLog/Files.src/M000121.html +19 -0
- data/doc/rdoc/classes/RequestLog/Objects.html +144 -0
- data/doc/rdoc/classes/RequestLog/Objects.src/M000122.html +19 -0
- data/doc/rdoc/classes/RequestLog/Params.html +144 -0
- data/doc/rdoc/classes/RequestLog/Params.src/M000123.html +19 -0
- data/doc/rdoc/classes/Stats.html +306 -0
- data/doc/rdoc/classes/Stats.src/M000009.html +19 -0
- data/doc/rdoc/classes/Stats.src/M000010.html +23 -0
- data/doc/rdoc/classes/Stats.src/M000011.html +26 -0
- data/doc/rdoc/classes/Stats.src/M000012.html +18 -0
- data/doc/rdoc/classes/Stats.src/M000013.html +18 -0
- data/doc/rdoc/classes/Stats.src/M000014.html +19 -0
- data/doc/rdoc/classes/Stats.src/M000015.html +20 -0
- data/doc/rdoc/classes/TCPServer.html +173 -0
- data/doc/rdoc/classes/TCPServer.src/M000007.html +19 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/COPYING.html +756 -0
- data/doc/rdoc/files/LICENSE.html +756 -0
- data/doc/rdoc/files/README.html +302 -0
- data/doc/rdoc/files/ext/http11/http11_c.html +101 -0
- data/doc/rdoc/files/lib/mongrel/camping_rb.html +108 -0
- data/doc/rdoc/files/lib/mongrel/cgi_rb.html +108 -0
- data/doc/rdoc/files/lib/mongrel/command_rb.html +111 -0
- data/doc/rdoc/files/lib/mongrel/debug_rb.html +110 -0
- data/doc/rdoc/files/lib/mongrel/handlers_rb.html +109 -0
- data/doc/rdoc/files/lib/mongrel/init_rb.html +109 -0
- data/doc/rdoc/files/lib/mongrel/rails_rb.html +111 -0
- data/doc/rdoc/files/lib/mongrel/stats_rb.html +117 -0
- data/doc/rdoc/files/lib/mongrel/tcphack_rb.html +109 -0
- data/doc/rdoc/files/lib/mongrel_rb.html +118 -0
- data/doc/rdoc/fr_class_index.html +60 -0
- data/doc/rdoc/fr_file_index.html +40 -0
- data/doc/rdoc/fr_method_index.html +149 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/examples/builder.rb +29 -0
- data/examples/camping/blog.rb +11 -2
- data/examples/simpletest.rb +20 -7
- data/ext/http11/http11.c +71 -14
- data/ext/http11/http11_parser.c +27 -24
- data/ext/http11/http11_parser.h +2 -1
- data/lib/http11.bundle +0 -0
- data/lib/mongrel.rb +498 -135
- data/lib/mongrel/command.rb +1 -1
- data/lib/mongrel/debug.rb +259 -0
- data/lib/mongrel/handlers.rb +76 -22
- data/lib/mongrel/rails.rb +165 -72
- data/lib/mongrel/stats.rb +71 -0
- data/test/test_configurator.rb +67 -0
- data/test/test_debug.rb +31 -0
- data/test/test_http11.rb +16 -0
- data/test/test_response.rb +5 -0
- data/test/test_stats.rb +28 -0
- metadata +224 -2
data/Rakefile
CHANGED
@@ -32,7 +32,7 @@ end
|
|
32
32
|
setup_extension("http11", "http11")
|
33
33
|
|
34
34
|
name="mongrel"
|
35
|
-
version="0.3.
|
35
|
+
version="0.3.12"
|
36
36
|
|
37
37
|
setup_gem(name, version) do |spec|
|
38
38
|
spec.summary = "A small fast HTTP library and server that runs Rails, Camping, and Nitro apps."
|
@@ -65,7 +65,7 @@ task :package_win32 do
|
|
65
65
|
spec.required_ruby_version = '>= 1.8.4'
|
66
66
|
|
67
67
|
spec.add_dependency('win32-service', '>= 0.5.0')
|
68
|
-
spec.add_dependency('gem_plugin', ">= 0.2")
|
68
|
+
spec.add_dependency('gem_plugin', ">= 0.2.1")
|
69
69
|
|
70
70
|
spec.extensions = []
|
71
71
|
spec.platform = Gem::Platform::WIN32
|
@@ -79,11 +79,13 @@ task :install do
|
|
79
79
|
sh %{sudo gem install pkg/mongrel-#{version}}
|
80
80
|
sub_project("mongrel_status", :install)
|
81
81
|
sub_project("mongrel_config", :install)
|
82
|
+
sub_project("mongrel_console", :install)
|
82
83
|
end
|
83
84
|
|
84
85
|
task :uninstall => [:clean] do
|
85
86
|
sub_project("mongrel_status", :uninstall)
|
86
87
|
sub_project("mongrel_config", :uninstall)
|
88
|
+
sub_project("mongrel_console", :uninstall)
|
87
89
|
sh %{sudo gem uninstall mongrel}
|
88
90
|
sub_project("gem_plugin", :uninstall)
|
89
91
|
end
|
data/bin/mongrel_rails
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
|
1
2
|
require 'rubygems'
|
2
3
|
require 'yaml'
|
3
|
-
require 'mongrel'
|
4
|
+
require 'mongrel/rails'
|
5
|
+
|
4
6
|
|
5
7
|
|
6
8
|
class Start < GemPlugin::Plugin "/commands"
|
@@ -14,11 +16,13 @@ class Start < GemPlugin::Plugin "/commands"
|
|
14
16
|
['-a', '--address ADDR', "Address to bind to", :@address, "0.0.0.0"],
|
15
17
|
['-l', '--log FILE', "Where to write log messages", :@log_file, "log/mongrel.log"],
|
16
18
|
['-P', '--pid FILE', "Where to write the PID", :@pid_file, "log/mongrel.pid"],
|
17
|
-
['-n', '--num-procs INT', "Number of processor threads to use", :@num_procs,
|
18
|
-
['-t', '--timeout SECONDS', "Timeout all requests after SECONDS time", :@timeout,
|
19
|
+
['-n', '--num-procs INT', "Number of processor threads to use", :@num_procs, 1024],
|
20
|
+
['-t', '--timeout SECONDS', "Timeout all requests after SECONDS time", :@timeout, 0],
|
19
21
|
['-m', '--mime PATH', "A YAML file that lists additional MIME types", :@mime_map, nil],
|
20
22
|
['-c', '--chdir PATH', "Change to dir before starting (will be expanded)", :@cwd, Dir.pwd],
|
21
23
|
['-r', '--root PATH', "Set the document root (default 'public')", :@docroot, "public"],
|
24
|
+
['-B', '--debug', "Enable debugging mode", :@debug, false],
|
25
|
+
['-C', '--config PATH', "Use a config file", :@config_file, nil]
|
22
26
|
]
|
23
27
|
end
|
24
28
|
|
@@ -33,119 +37,72 @@ class Start < GemPlugin::Plugin "/commands"
|
|
33
37
|
valid_dir? File.dirname(@pid_file), "Path to pid file not valid: #@pid_file"
|
34
38
|
valid_dir? @docroot, "Path to docroot not valid: #@docroot"
|
35
39
|
valid_exists? @mime_map, "MIME mapping file does not exist: #@mime_map" if @mime_map
|
36
|
-
|
40
|
+
valid_exists? @config_file, "Config file not there: #@config_file" if @config_file
|
37
41
|
return @valid
|
38
42
|
end
|
39
43
|
|
44
|
+
def run
|
40
45
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
open(@pid_file,"w") {|f| f.write(Process.pid) }
|
53
|
-
else
|
54
|
-
puts "Running Mongrel server in #@environment mode at #@address:#@port"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def load_mime_map
|
59
|
-
mime = {}
|
60
|
-
|
61
|
-
# configure any requested mime map
|
62
|
-
if @mime_map
|
63
|
-
puts "Loading additional MIME types from #@mime_map"
|
64
|
-
mime.merge!(YAML.load_file(@mime_map))
|
65
|
-
|
66
|
-
# check all the mime types to make sure they are the right format
|
67
|
-
mime.each {|k,v| puts "WARNING: MIME type #{k} must start with '.'" if k.index(".") != 0 }
|
46
|
+
# command line setting override config file settings
|
47
|
+
settings = { :host => @address, :port => @port, :cwd => @cwd,
|
48
|
+
:log_file => @log_file, :pid_file => @pid_file, :environment => @environment,
|
49
|
+
:docroot => @docroot, :mime_map => @mime_map, :daemon => @daemon,
|
50
|
+
:debug => @debug, :includes => ["mongrel"]
|
51
|
+
}
|
52
|
+
|
53
|
+
if @config_file
|
54
|
+
STDERR.puts "** Loading settings from #{@config_file} (command line options override)."
|
55
|
+
conf = YAML.load_file(@config_file)
|
56
|
+
settings = conf.merge(settings)
|
68
57
|
end
|
69
58
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
server.stop
|
100
|
-
File.unlink @pid_file if File.exist?(@pid_file)
|
101
|
-
}
|
102
|
-
|
103
|
-
# rails reload
|
104
|
-
trap("HUP") {
|
105
|
-
STDERR.puts "Reloading rails..."
|
106
|
-
rails.reload!
|
107
|
-
STDERR.puts "Done reloading rails."
|
108
|
-
}
|
109
|
-
|
110
|
-
# restart
|
111
|
-
trap("USR2") {
|
112
|
-
server.stop
|
113
|
-
File.unlink @pid_file if File.exist?(@pid_file)
|
114
|
-
@restart = true
|
115
|
-
}
|
59
|
+
config = Mongrel::Rails::RailsConfigurator.new(settings) do
|
60
|
+
log "Starting Mongrel in #{settings[:environment]} mode at #{settings[:host]}:#{settings[:port]}"
|
61
|
+
|
62
|
+
if defaults[:daemon]
|
63
|
+
log "Daemonizing, any open files are closed. Look at #{settings[:pid_file]} and #{settings[:log_file]} for info."
|
64
|
+
daemonize
|
65
|
+
end
|
66
|
+
|
67
|
+
listener do
|
68
|
+
mime = {}
|
69
|
+
if defaults[:mime_map]
|
70
|
+
log "Loading additional MIME types from #{settings[:mime_map]}"
|
71
|
+
mime = load_mime_map(defaults[:mime_map], mime)
|
72
|
+
end
|
73
|
+
|
74
|
+
if defaults[:debug]
|
75
|
+
log "Installing debugging prefixed filters. Look in log/mongrel_debug for the files."
|
76
|
+
debug "/"
|
77
|
+
end
|
78
|
+
|
79
|
+
log "Starting Rails in environment #{settings[:environment]} ..."
|
80
|
+
uri "/", :handler => rails
|
81
|
+
log "Rails loaded."
|
82
|
+
|
83
|
+
log "Loading any Rails specific GemPlugins"
|
84
|
+
load_plugins
|
85
|
+
|
86
|
+
setup_rails_signals
|
87
|
+
end
|
116
88
|
end
|
117
89
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
begin
|
122
|
-
# start mongrel processing thread
|
123
|
-
server.run
|
90
|
+
config.run
|
91
|
+
config.log "Mongrel available at #{settings[:host]}:#{settings[:port]}"
|
92
|
+
config.join
|
124
93
|
|
94
|
+
if config.needs_restart
|
125
95
|
if RUBY_PLATFORM !~ /mswin/
|
126
|
-
|
96
|
+
cmd = "ruby #{__FILE__} start #{original_args.join(' ')}"
|
97
|
+
config.log "Restarting with arguments: #{cmd}"
|
98
|
+
exec cmd
|
127
99
|
else
|
128
|
-
|
100
|
+
config.log "Win32 does not support restarts. Exiting."
|
129
101
|
end
|
130
|
-
|
131
|
-
server.acceptor.join
|
132
|
-
rescue Interrupt
|
133
|
-
STDERR.puts "Interrupted."
|
134
|
-
raise
|
135
102
|
end
|
136
|
-
|
137
|
-
# daemonize makes restart easy
|
138
|
-
run if @restart
|
139
|
-
end
|
140
|
-
|
141
|
-
def run
|
142
|
-
daemonize
|
143
|
-
rails = configure_rails
|
144
|
-
start_mongrel(rails)
|
145
103
|
end
|
146
104
|
end
|
147
105
|
|
148
|
-
|
149
106
|
def send_signal(signal, pid_file)
|
150
107
|
pid = open(pid_file).read.to_i
|
151
108
|
print "Sending #{signal} to Mongrel at PID #{pid}..."
|
@@ -223,6 +180,13 @@ class Restart < GemPlugin::Plugin "/commands"
|
|
223
180
|
end
|
224
181
|
end
|
225
182
|
|
183
|
+
|
226
184
|
GemPlugin::Manager.instance.load "mongrel" => GemPlugin::INCLUDE, "rails" => GemPlugin::EXCLUDE
|
227
185
|
|
228
|
-
|
186
|
+
|
187
|
+
if not Mongrel::Command::Registry.instance.run ARGV
|
188
|
+
exit 1
|
189
|
+
end
|
190
|
+
|
191
|
+
|
192
|
+
|
data/bin/mongrel_rails_service
CHANGED
@@ -80,7 +80,7 @@ class Install < GemPlugin::Plugin "/commands"
|
|
80
80
|
end
|
81
81
|
|
82
82
|
# Expand to get full path for mime-types file
|
83
|
-
@mime_map = File.
|
83
|
+
@mime_map = File.expand_path(@mime_map) if @mime_map
|
84
84
|
|
85
85
|
# default service display to service name
|
86
86
|
@svc_display = @svc_name if !@svc_display
|
data/bin/mongrel_rails_svc
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
# This is where Win32::Daemon resides.
|
5
5
|
###############################################
|
6
6
|
require 'rubygems'
|
7
|
+
require 'mongrel'
|
7
8
|
require 'mongrel/rails'
|
8
9
|
require 'optparse'
|
9
10
|
require 'win32/service'
|
@@ -70,14 +71,15 @@ class MongrelRails
|
|
70
71
|
|
71
72
|
def delayed_initialize
|
72
73
|
dbg "delayed_initialize entered"
|
73
|
-
|
74
|
+
|
74
75
|
@rails = configure_rails
|
75
76
|
|
76
77
|
# start up mongrel with the right configurations
|
77
78
|
@server = Mongrel::HttpServer.new(@ip, @port, @num_procs.to_i, @timeout.to_i)
|
78
79
|
@server.register("/", @rails)
|
79
|
-
|
80
|
+
|
80
81
|
dbg "delayed_initialize left"
|
82
|
+
|
81
83
|
end
|
82
84
|
|
83
85
|
def load_mime_map
|
@@ -104,11 +106,12 @@ class MongrelRails
|
|
104
106
|
|
105
107
|
Dir.chdir(@rails_root)
|
106
108
|
|
109
|
+
|
107
110
|
ENV['RAILS_ENV'] = @environment
|
108
|
-
require
|
111
|
+
require 'config/environment'
|
109
112
|
|
110
113
|
# configure the rails handler
|
111
|
-
rails = RailsHandler.new(@docroot, load_mime_map)
|
114
|
+
rails = Mongrel::Rails::RailsHandler.new(@docroot, load_mime_map)
|
112
115
|
|
113
116
|
dbg "configure_rails left"
|
114
117
|
|
@@ -116,24 +119,29 @@ class MongrelRails
|
|
116
119
|
end
|
117
120
|
|
118
121
|
def start_serve
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
122
|
+
begin
|
123
|
+
dbg "start_serve entered"
|
124
|
+
|
125
|
+
@runner = Thread.new do
|
126
|
+
dbg_th "runner_thread suspended"
|
127
|
+
Thread.stop
|
128
|
+
|
129
|
+
dbg_th "runner_thread resumed"
|
130
|
+
dbg_th "runner_thread acceptor.join"
|
131
|
+
@server.acceptor.join
|
132
|
+
end
|
124
133
|
|
125
|
-
|
126
|
-
|
127
|
-
|
134
|
+
dbg "server.run"
|
135
|
+
@server.run
|
136
|
+
|
137
|
+
dbg "runner.run"
|
138
|
+
@runner.run
|
139
|
+
|
140
|
+
dbg "start_serve left"
|
141
|
+
rescue
|
142
|
+
dbg "ERROR: #$!\r\n"
|
143
|
+
dbg $!.backtrace.join("\r\n")
|
128
144
|
end
|
129
|
-
|
130
|
-
dbg "server.run"
|
131
|
-
@server.run
|
132
|
-
|
133
|
-
dbg "runner.run"
|
134
|
-
@runner.run
|
135
|
-
|
136
|
-
dbg "start_serve left"
|
137
145
|
end
|
138
146
|
|
139
147
|
def stop_serve
|
@@ -193,99 +201,107 @@ class RailsDaemon < Win32::Daemon
|
|
193
201
|
end
|
194
202
|
|
195
203
|
|
196
|
-
|
197
|
-
ARGV
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
ARGV
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
204
|
+
begin
|
205
|
+
if ARGV[0] == 'service'
|
206
|
+
ARGV.shift
|
207
|
+
|
208
|
+
# default options
|
209
|
+
OPTIONS = {
|
210
|
+
:rails_root => Dir.pwd,
|
211
|
+
:environment => 'production',
|
212
|
+
:ip => '0.0.0.0',
|
213
|
+
:port => 3000,
|
214
|
+
:mime_map => nil,
|
215
|
+
:num_procs => 1024,
|
216
|
+
:timeout => 0,
|
217
|
+
:cpu => nil
|
218
|
+
}
|
219
|
+
|
220
|
+
ARGV.options do |opts|
|
221
|
+
opts.on('-r', '--root PATH', "Set the root path where your rails app resides.") { |OPTIONS[:rails_root]| }
|
222
|
+
opts.on('-e', '--environment ENV', "Rails environment to run as. (default: production)") { |OPTIONS[:environment]| }
|
223
|
+
opts.on('-b', '--binding ADDR', "Address to bind to") { |OPTIONS[:ip]| }
|
224
|
+
opts.on('-p', '--port PORT', "Which port to bind to") { |OPTIONS[:port]| }
|
225
|
+
opts.on('-m', '--mime PATH', "A YAML file that lists additional MIME types") { |OPTIONS[:mime_map]| }
|
226
|
+
opts.on('-P', '--num-procs INT', "Number of processor threads to use") { |OPTIONS[:num_procs]| }
|
227
|
+
opts.on('-t', '--timeout SECONDS', "Timeout all requests after SECONDS time") { |OPTIONS[:timeout]| }
|
228
|
+
opts.on('-c', '--cpu CPU', "Bind the process to specific cpu") { |OPTIONS[:cpu]| }
|
229
|
+
|
230
|
+
opts.parse!
|
231
|
+
end
|
232
|
+
|
233
|
+
#expand RAILS_ROOT
|
234
|
+
OPTIONS[:rails_root] = File.expand_path(OPTIONS[:rails_root])
|
235
|
+
|
236
|
+
OPTIONS[:docroot] = File.expand_path(OPTIONS[:rails_root] + '/public')
|
237
|
+
|
238
|
+
# We must bind to a specific cpu?
|
239
|
+
if OPTIONS[:cpu]
|
240
|
+
Kernel32.set_affinity(Process.pid, OPTIONS[:cpu])
|
241
|
+
end
|
242
|
+
|
243
|
+
rails = MongrelRails.new(OPTIONS[:ip], OPTIONS[:port], OPTIONS[:rails_root], OPTIONS[:docroot], OPTIONS[:environment], OPTIONS[:mime_map], OPTIONS[:num_procs].to_i, OPTIONS[:timeout].to_i)
|
244
|
+
rails_svc = RailsDaemon.new(rails)
|
245
|
+
rails_svc.mainloop
|
246
|
+
|
247
|
+
elsif ARGV[0] == 'debug'
|
248
|
+
ARGV.shift
|
249
|
+
|
250
|
+
# default options
|
251
|
+
OPTIONS = {
|
252
|
+
:rails_root => Dir.pwd,
|
253
|
+
:environment => 'production',
|
254
|
+
:ip => '0.0.0.0',
|
255
|
+
:port => 3000,
|
256
|
+
:mime_map => nil,
|
257
|
+
:num_procs => 20,
|
258
|
+
:timeout => 120,
|
259
|
+
:cpu => nil
|
260
|
+
}
|
261
|
+
|
262
|
+
ARGV.options do |opts|
|
263
|
+
opts.on('-r', '--root PATH', "Set the root path where your rails app resides.") { |OPTIONS[:rails_root]| }
|
264
|
+
opts.on('-e', '--environment ENV', "Rails environment to run as.") { |OPTIONS[:environment]| }
|
265
|
+
opts.on('-b', '--binding ADDR', "Address to bind to") { |OPTIONS[:ip]| }
|
266
|
+
opts.on('-p', '--port PORT', "Which port to bind to") { |OPTIONS[:port]| }
|
267
|
+
opts.on('-m', '--mime PATH', "A YAML file that lists additional MIME types") { |OPTIONS[:mime_map]| }
|
268
|
+
opts.on('-P', '--num-procs INT', "Number of processor threads to use") { |OPTIONS[:num_procs]| }
|
269
|
+
opts.on('-t', '--timeout SECONDS', "Timeout all requests after SECONDS time") { |OPTIONS[:timeout]| }
|
270
|
+
opts.on('-c', '--cpu CPU', "Bind the process to specific cpu") { |OPTIONS[:cpu]| }
|
271
|
+
|
272
|
+
opts.parse!
|
273
|
+
end
|
274
|
+
|
275
|
+
#expand RAILS_ROOT
|
276
|
+
OPTIONS[:rails_root] = File.expand_path(OPTIONS[:rails_root])
|
277
|
+
|
278
|
+
OPTIONS[:docroot] = File.expand_path(OPTIONS[:rails_root] + '/public')
|
279
|
+
|
280
|
+
# We must bind to a specific cpu?
|
281
|
+
if OPTIONS[:cpu]
|
282
|
+
Kernel32.set_affinity(Process.pid, OPTIONS[:cpu])
|
283
|
+
end
|
284
|
+
|
285
|
+
rails = MongrelRails.new(OPTIONS[:ip], OPTIONS[:port], OPTIONS[:rails_root], OPTIONS[:docroot], OPTIONS[:environment], OPTIONS[:mime_map], OPTIONS[:num_procs].to_i, OPTIONS[:timeout].to_i)
|
286
|
+
rails.delayed_initialize
|
287
|
+
rails.start_serve
|
288
|
+
|
289
|
+
begin
|
290
|
+
sleep
|
291
|
+
rescue Interrupt
|
292
|
+
dbg "ERROR: #$!\r\n"
|
293
|
+
dbg $!.backtrace.join("\r\n")
|
294
|
+
puts "graceful shutdown?"
|
295
|
+
end
|
296
|
+
|
297
|
+
begin
|
298
|
+
rails.stop_serve
|
299
|
+
rescue
|
300
|
+
dbg "ERROR: #$!\r\n"
|
301
|
+
dbg $!.backtrace.join("\r\n")
|
302
|
+
end
|
303
|
+
end
|
304
|
+
rescue
|
305
|
+
dbg "ERROR: #$!\r\n"
|
306
|
+
dbg $!.backtrace.join("\r\n")
|
291
307
|
end
|