mongrel 1.1.5-x86-mingw32 → 1.2.0.pre2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/History.txt +68 -0
  2. data/{Manifest → Manifest.txt} +15 -15
  3. data/{README → README.txt} +6 -0
  4. data/Rakefile +8 -0
  5. data/bin/mongrel_rails +5 -4
  6. data/examples/camping/blog.rb +0 -0
  7. data/ext/{http11_java → http11}/Http11Service.java +0 -0
  8. data/ext/http11/ext_help.h +1 -0
  9. data/ext/http11/http11.c +152 -20
  10. data/ext/http11/http11_parser.c +262 -240
  11. data/ext/http11/http11_parser.java.rl +3 -14
  12. data/ext/http11/http11_parser.rl +19 -18
  13. data/ext/http11/http11_parser_common.rl +1 -1
  14. data/ext/{http11_java → http11}/org/jruby/mongrel/Http11.java +37 -62
  15. data/ext/http11/org/jruby/mongrel/Http11Parser.java +486 -0
  16. data/lib/1.8/http11.so +0 -0
  17. data/lib/1.9/http11.so +0 -0
  18. data/lib/mongrel.rb +16 -5
  19. data/lib/mongrel/cgi.rb +2 -2
  20. data/lib/mongrel/command.rb +1 -3
  21. data/lib/mongrel/configurator.rb +5 -5
  22. data/lib/mongrel/const.rb +1 -1
  23. data/lib/mongrel/handlers.rb +5 -5
  24. data/lib/mongrel/http_request.rb +1 -1
  25. data/lib/mongrel/http_response.rb +4 -1
  26. data/lib/mongrel/rails.rb +1 -1
  27. data/tasks/gem.rake +28 -0
  28. data/tasks/native.rake +24 -0
  29. data/tasks/ragel.rake +20 -0
  30. data/test/test_conditional.rb +2 -2
  31. data/test/test_configurator.rb +4 -5
  32. data/test/test_handlers.rb +33 -24
  33. data/test/test_redirect_handler.rb +2 -3
  34. data/test/test_request_progress.rb +4 -5
  35. data/test/test_ws.rb +2 -0
  36. data/test/testhelp.rb +1 -9
  37. metadata +86 -86
  38. data.tar.gz.sig +0 -4
  39. data/CHANGELOG +0 -18
  40. data/examples/mongrel_simple_ctrl.rb +0 -92
  41. data/examples/mongrel_simple_service.rb +0 -116
  42. data/ext/http11_java/org/jruby/mongrel/Http11Parser.java +0 -572
  43. data/lib/http11.so +0 -0
  44. data/mongrel-public_cert.pem +0 -20
  45. data/mongrel.gemspec +0 -242
  46. metadata.gz.sig +0 -1
@@ -93,6 +93,8 @@ class WebServerTest < Test::Unit::TestCase
93
93
  end
94
94
 
95
95
  def test_num_processors_overload
96
+ # Skipped this for Windows until further investigation
97
+ return if RUBY_PLATFORM =~ /mingw|mswin/
96
98
  redirect_test_io do
97
99
  assert_raises Errno::ECONNRESET, Errno::EPIPE, Errno::ECONNABORTED, Errno::EINVAL, IOError do
98
100
  tests = [
@@ -65,15 +65,7 @@ def hit(uris)
65
65
  return results
66
66
  end
67
67
 
68
- # process_based_port provides a port number, usable for TCP and UDP
69
- # connections based on $$ and with a 6000 as base.
70
- # this is required if you perform several builds of mongrel in parallel
71
- # (like continuous integration systems)
72
- def process_based_port
73
- 6000 + $$ % 1000
74
- end
75
-
76
68
  # Platform check helper ;-)
77
69
  def windows?
78
- result = RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/
70
+ result = RUBY_PLATFORM =~ /mingw|mswin/
79
71
  end
metadata CHANGED
@@ -1,58 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongrel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.2.0.pre2
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Zed A. Shaw
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDUDCCAjigAwIBAgIBADANBgkqhkiG9w0BAQUFADBOMRwwGgYDVQQDDBNtb25n
14
- cmVsLWRldmVsb3BtZW50MRkwFwYKCZImiZPyLGQBGRYJcnVieWZvcmdlMRMwEQYK
15
- CZImiZPyLGQBGRYDb3JnMB4XDTA3MDkxNjEwMzI0OVoXDTA4MDkxNTEwMzI0OVow
16
- TjEcMBoGA1UEAwwTbW9uZ3JlbC1kZXZlbG9wbWVudDEZMBcGCgmSJomT8ixkARkW
17
- CXJ1Ynlmb3JnZTETMBEGCgmSJomT8ixkARkWA29yZzCCASIwDQYJKoZIhvcNAQEB
18
- BQADggEPADCCAQoCggEBAMb9v3B01eOHk3FyypbQgKXzJplUE5P6dXoG+xpPm0Lv
19
- P7BQmeMncOwqQ7zXpVQU+lTpXtQFTsOE3vL7KnhQFJKGvUAkbh24VFyopu1I0yqF
20
- mGu4nRqNXGXVj8TvLSj4S1WpSRLAa0acLPNyKhGmoV9+crqQypSjM6XKjBeppifo
21
- 4eBmWGjiJEYMIJBvJZPJ4rAVDDA8C6CM1m3gMBGNh8ELDhU8HI9AP3dMIkTI2Wx9
22
- 9xkJwHdroAaS0IFFtYChrwee4FbCF1FHDgoTosMwa47DrLHg4hZ6ojaKwK5QVWEV
23
- XGb6ju5UqpktnSWF2W+Lvl/K0tI42OH2CAhebT1gEVUCAwEAAaM5MDcwCQYDVR0T
24
- BAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFGHChyMSZ16u9WOzKhgJSQ9lqDc5
25
- MA0GCSqGSIb3DQEBBQUAA4IBAQA/lfeN2WdB1xN+82tT7vNS4HOjRQw6MUh5yktu
26
- GQjaGqm0UB+aX0Z9y0B0qpfv9rj7nmIvEGiwBmDepNWYCGuW15JyqpN7QVVnG2xS
27
- Mrame7VqgjM7A+VGDD5In5LtWbM/CHAATvvFlQ5Ph13YE1EdnVbZ65c+KQv+5sFY
28
- Q+zEop74d878uaC/SAHHXS46TiXneocaLSYw1CEZs/MAIy+9c4Q5ESbGpgnfg1Ad
29
- 6lwl7k3hsNHO/+tZzx4HJtOXDI1yAl3+q6T9J0yI3z97EinwvAKhS1eyOI2Y5eeT
30
- tbQaNYkU127B3l/VNpd8fQm3Jkl/PqCCmDBQjUszFrJEODug
31
- -----END CERTIFICATE-----
10
+ cert_chain: []
32
11
 
33
- - |
34
- -----BEGIN CERTIFICATE-----
35
- MIIDQzCCAiugAwIBAgIBADANBgkqhkiG9w0BAQUFADBOMRwwGgYDVQQDDBNtb25n
36
- cmVsLWRldmVsb3BtZW50MRkwFwYKCZImiZPyLGQBGRYJcnVieWZvcmdlMRMwEQYK
37
- CZImiZPyLGQBGRYDb3JnMB4XDTA3MDkyNDAyMzAzOVoXDTA4MDkyMzAyMzAzOVow
38
- QTETMBEGA1UEAwwKbHVpc2xhdmVuYTEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMw
39
- EQYKCZImiZPyLGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
40
- AQEA5gIWDL7FYk43BEM3guuNz1vrr2RW7UAh+KY8w2+cGxt+MNi3P+rrfx/LAr7d
41
- KKV+RT7PQgutb9MZhk8ghn0qgTpCxWbvlhnFrMqIDaJy9nXGEWt6M0fTWdEojrzF
42
- dLSO//3GYzZze/ykE20KeNZ8SXzbxPwmIwrKfvoGYshGdmU7RAwiV6vV9ZS4uB1I
43
- /pvzsWp3cSqZwxJvtb7P445jcDMPqFXjMFVAXd6KpfVNl4ZNBzYHc0Ii2uLu3Pv4
44
- jOmwvJlYZ30ccBh0G86ngtlOpZNrdcnXgRKXADGnxPickYZMdIHPPykIeR6Im0sR
45
- hCq6hsHkuWQU6CuwqTtGErw6uwIDAQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQE
46
- AwIEsDAdBgNVHQ4EFgQUkz5QYICmPVaUs8rhPOQmhrDosCUwDQYJKoZIhvcNAQEF
47
- BQADggEBAMVgi+dtUNn1WNgsrkDi8wPkBbTj4qvTdu/mLncUD/wSNEfaf0ADiycu
48
- W9x8imY3UmSyyc2HO+/Wnf6/PkbaoAcUZxl/7a60UDqSyTpdpfB3moA7z9+j+Kyp
49
- nVFr7JVQG3SSNC/y0XrYf6J0DCgpLwOqLSes/KaQOtJlXl/xV37AHXEnAPjwJyCD
50
- qafzGwoObqIf7Vj8IzU/eoCx/SxAYnaevry1bls58eb28FKGuq7bWyJuDrFu1H8m
51
- mPG0Kv6rJ8vKyQiYZMAKm+XpuDZ09rnGm3ytdeEpXDfF5osSDDBSlWox82z2ulMd
52
- knPjAuGZt50yNl1teBnVEZkty2RINfo=
53
- -----END CERTIFICATE-----
54
-
55
- date: 2008-08-16 00:00:00 +02:00
12
+ date: 2010-03-18 00:00:00 -03:00
56
13
  default_executable:
57
14
  dependencies:
58
15
  - !ruby/object:Gem::Dependency
@@ -61,41 +18,83 @@ dependencies:
61
18
  version_requirement:
62
19
  version_requirements: !ruby/object:Gem::Requirement
63
20
  requirements:
64
- - - ">="
21
+ - - ~>
65
22
  - !ruby/object:Gem::Version
66
23
  version: 0.2.3
67
24
  version:
68
25
  - !ruby/object:Gem::Dependency
69
- name: cgi_multipart_eof_fix
70
- type: :runtime
26
+ name: rubyforge
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.3
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: gemcutter
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.3.0
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: rake-compiler
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.7.0
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: hoe
57
+ type: :development
71
58
  version_requirement:
72
59
  version_requirements: !ruby/object:Gem::Requirement
73
60
  requirements:
74
61
  - - ">="
75
62
  - !ruby/object:Gem::Version
76
- version: "2.4"
63
+ version: 2.5.0
77
64
  version:
78
- description: A small fast HTTP library and server that runs Rails, Camping, Nitro and Iowa apps.
79
- email: ""
65
+ description: |-
66
+ Mongrel is a small library that provides a very fast HTTP 1.1 server for Ruby web applications. It is not particular to any framework, and is intended to be just enough to get a web application running behind a more complete and robust web server.
67
+
68
+ What makes Mongrel so fast is the careful use of an Ragel extension to provide fast, accurate HTTP 1.1 protocol parsing. This makes the server scream without too many portability issues.
69
+
70
+ See http://mongrel.rubyforge.org for more information.
71
+ email:
72
+ - mongrel-users@rubyforge.org
80
73
  executables:
81
74
  - mongrel_rails
82
75
  extensions: []
83
76
 
84
- extra_rdoc_files: []
85
-
77
+ extra_rdoc_files:
78
+ - History.txt
79
+ - Manifest.txt
80
+ - README.txt
81
+ - LICENSE
86
82
  files:
87
- - bin/mongrel_rails
88
- - CHANGELOG
89
83
  - COPYING
84
+ - History.txt
85
+ - LICENSE
86
+ - Manifest.txt
87
+ - README.txt
88
+ - Rakefile
89
+ - TODO
90
+ - bin/mongrel_rails
90
91
  - examples/builder.rb
91
- - examples/camping/blog.rb
92
92
  - examples/camping/README
93
+ - examples/camping/blog.rb
93
94
  - examples/camping/tepee.rb
94
95
  - examples/httpd.conf
95
96
  - examples/mime.yaml
96
97
  - examples/mongrel.conf
97
- - examples/mongrel_simple_ctrl.rb
98
- - examples/mongrel_simple_service.rb
99
98
  - examples/monitrc
100
99
  - examples/random_thrash.rb
101
100
  - examples/simpletest.rb
@@ -108,9 +107,10 @@ files:
108
107
  - ext/http11/http11_parser.java.rl
109
108
  - ext/http11/http11_parser.rl
110
109
  - ext/http11/http11_parser_common.rl
111
- - ext/http11_java/Http11Service.java
112
- - ext/http11_java/org/jruby/mongrel/Http11.java
113
- - ext/http11_java/org/jruby/mongrel/Http11Parser.java
110
+ - ext/http11/Http11Service.java
111
+ - ext/http11/org/jruby/mongrel/Http11.java
112
+ - ext/http11/org/jruby/mongrel/Http11Parser.java
113
+ - lib/mongrel.rb
114
114
  - lib/mongrel/camping.rb
115
115
  - lib/mongrel/cgi.rb
116
116
  - lib/mongrel/command.rb
@@ -128,13 +128,10 @@ files:
128
128
  - lib/mongrel/stats.rb
129
129
  - lib/mongrel/tcphack.rb
130
130
  - lib/mongrel/uri_classifier.rb
131
- - lib/mongrel.rb
132
- - LICENSE
133
- - Manifest
134
- - mongrel-public_cert.pem
135
- - mongrel.gemspec
136
- - README
137
131
  - setup.rb
132
+ - tasks/gem.rake
133
+ - tasks/native.rake
134
+ - tasks/ragel.rake
138
135
  - test/mime.yaml
139
136
  - test/mongrel.conf
140
137
  - test/test_cgi_wrapper.rb
@@ -151,14 +148,17 @@ files:
151
148
  - test/test_uriclassifier.rb
152
149
  - test/test_ws.rb
153
150
  - test/testhelp.rb
154
- - TODO
155
151
  - tools/trickletest.rb
156
- - lib/http11.so
152
+ - lib/1.8/http11.so
153
+ - lib/1.9/http11.so
157
154
  has_rdoc: true
158
- homepage: http://mongrel.rubyforge.org
159
- post_install_message:
160
- rdoc_options: []
155
+ homepage: http://mongrel.rubyforge.org/
156
+ licenses: []
161
157
 
158
+ post_install_message:
159
+ rdoc_options:
160
+ - --main
161
+ - README.txt
162
162
  require_paths:
163
163
  - lib
164
164
  - ext
@@ -166,32 +166,32 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
166
  requirements:
167
167
  - - ">="
168
168
  - !ruby/object:Gem::Version
169
- version: 1.8.4
169
+ version: 1.8.6
170
170
  version:
171
171
  required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  requirements:
173
- - - ">="
173
+ - - ">"
174
174
  - !ruby/object:Gem::Version
175
- version: "0"
175
+ version: 1.3.1
176
176
  version:
177
177
  requirements: []
178
178
 
179
179
  rubyforge_project: mongrel
180
- rubygems_version: 1.2.0
180
+ rubygems_version: 1.3.5
181
181
  signing_key:
182
- specification_version: 2
183
- summary: A small fast HTTP library and server that runs Rails, Camping, Nitro and Iowa apps.
182
+ specification_version: 3
183
+ summary: Mongrel is a small library that provides a very fast HTTP 1.1 server for Ruby web applications
184
184
  test_files:
185
- - test/test_cgi_wrapper.rb
186
- - test/test_command.rb
187
- - test/test_conditional.rb
185
+ - test/test_http11.rb
186
+ - test/test_uriclassifier.rb
187
+ - test/test_response.rb
188
188
  - test/test_configurator.rb
189
- - test/test_debug.rb
189
+ - test/test_conditional.rb
190
190
  - test/test_handlers.rb
191
- - test/test_http11.rb
192
191
  - test/test_redirect_handler.rb
192
+ - test/test_debug.rb
193
193
  - test/test_request_progress.rb
194
- - test/test_response.rb
195
194
  - test/test_stats.rb
196
- - test/test_uriclassifier.rb
195
+ - test/test_command.rb
197
196
  - test/test_ws.rb
197
+ - test/test_cgi_wrapper.rb
data.tar.gz.sig DELETED
@@ -1,4 +0,0 @@
1
- �W�K�բ~��c�EVf������jzV���f���*4 _�K�� � N�1��Iܤ���Vj���1���B:
2
- �����1}���"�����'��L�1y>��OJ.W`{Ȩ�N >]Ӝ��b�M��T�h���x�����8#�͈
3
- �T�Hh���h��rs���wj|�� 
4
- r�������J�F6~0Q��w������O�'����U��S�w��v٥G!�iC�*vh�À�Hh�6bÑ�R�8
data/CHANGELOG DELETED
@@ -1,18 +0,0 @@
1
-
2
- v1.1.5. Fix bug where num_processors is not actually set from mongrel_rails.
3
-
4
- v1.1.4. Fix camping handler. Correct treatment of @throttle parameter.
5
-
6
- v1.1.3. Fix security flaw of DirHandler; reported on mailing list.
7
-
8
- v1.1.2. Fix worker termination bug; fix JRuby 1.0.3 load order issue; fix require issue on systems without Rubygems.
9
-
10
- v1.1.1. Fix mongrel_rails restart bug; fix bug with Rack status codes.
11
-
12
- v1.1. Pure Ruby URIClassifier. More modular architecture. JRuby support. Move C URIClassifier into mongrel_experimental project.
13
-
14
- v1.0.4. Backport fixes for versioning inconsistency, mongrel_rails bug, and DirHandler bug.
15
-
16
- v1.0.3. Fix user-switching bug; make people upgrade to the latest from the RC.
17
-
18
- v1.0.2. Signed gem; many minor bugfixes and patches.
@@ -1,92 +0,0 @@
1
- ###############################################
2
- # mongrel_simple_ctrl.rb
3
- #
4
- # Control script for the Mongrel server
5
- ###############################################
6
- require "optparse"
7
- require "win32/service"
8
- include Win32
9
-
10
- # I start the service name with an 'A' so that it appears at the top
11
- SERVICE_NAME = "MongrelSvc"
12
- SERVICE_DISPLAYNAME = "Mongrel HTTP Server"
13
- SCRIPT_ROOT = File.join(File.dirname(__FILE__), '.')
14
- SCRIPT_NAME = "mongrel_simple_service.rb"
15
- SERVICE_SCRIPT = File.expand_path(SCRIPT_ROOT + '/' + SCRIPT_NAME)
16
-
17
- OPTIONS = {}
18
-
19
- ARGV.options do |opts|
20
- opts.on("-d", "--delete", "Delete the service"){ OPTIONS[:delete] = true }
21
- opts.on("-u", "--uninstall","Delete the service"){ OPTIONS[:uninstall] = true }
22
- opts.on("-s", "--start", "Start the service"){ OPTIONS[:start] = true }
23
- opts.on("-x", "--stop", "Stop the service"){ OPTIONS[:stop] = true }
24
- opts.on("-i", "--install","Install the service"){ OPTIONS[:install] = true }
25
-
26
- opts.on("-h", "--help", "Show this help message."){ puts opts; exit }
27
-
28
- opts.parse!
29
- end
30
-
31
- # Install the service
32
- if OPTIONS[:install]
33
- require 'rbconfig'
34
-
35
- svc = Service.new
36
- svc.create_service{ |s|
37
- s.service_name = SERVICE_NAME
38
- s.display_name = SERVICE_DISPLAYNAME
39
- s.binary_path_name = Config::CONFIG['bindir'] + '/ruby ' + SERVICE_SCRIPT
40
- s.dependencies = []
41
- }
42
- svc.close
43
- puts "#{SERVICE_DISPLAYNAME} service installed"
44
- end
45
-
46
- # Start the service
47
- if OPTIONS[:start]
48
- Service.start(SERVICE_NAME)
49
- started = false
50
- while started == false
51
- s = Service.status(SERVICE_NAME)
52
- started = true if s.current_state == "running"
53
- break if started == true
54
- puts "One moment, " + s.current_state
55
- sleep 1
56
- end
57
- puts "#{SERVICE_DISPLAYNAME} service started"
58
- end
59
-
60
- # Stop the service
61
- if OPTIONS[:stop]
62
- Service.stop(SERVICE_NAME)
63
- stopped = false
64
- while stopped == false
65
- s = Service.status(SERVICE_NAME)
66
- stopped = true if s.current_state == "stopped"
67
- break if stopped == true
68
- puts "One moment, " + s.current_state
69
- sleep 1
70
- end
71
- puts "#{SERVICE_DISPLAYNAME} service stopped"
72
- end
73
-
74
- # Delete the service. Stop it first.
75
- if OPTIONS[:delete] || OPTIONS[:uninstall]
76
- begin
77
- Service.stop(SERVICE_NAME)
78
- rescue
79
- end
80
- begin
81
- Service.delete(SERVICE_NAME)
82
- rescue
83
- end
84
- puts "#{SERVICE_DISPLAYNAME} service deleted"
85
- end
86
- # END mongrel_rails_ctrl.rb
87
-
88
-
89
-
90
-
91
-
92
-
@@ -1,116 +0,0 @@
1
- # This script emualtes script/server behavior but running webrick http server
2
- require 'rubygems'
3
-
4
- require 'mongrel'
5
- require 'yaml'
6
- require 'zlib'
7
-
8
- require 'win32/service'
9
-
10
- DEBUG_LOG_FILE = File.expand_path(File.dirname(__FILE__) + '/debug.log')
11
-
12
- class SimpleHandler < Mongrel::HttpHandler
13
- def process(request, response)
14
- response.start do |head,out|
15
- head["Content-Type"] = "text/html"
16
- results = "<html><body>Your request:<br /><pre>#{request.params.to_yaml}</pre><a href=\"/files\">View the files.</a></body></html>"
17
- if request.params["HTTP_ACCEPT_ENCODING"] == "gzip,deflate"
18
- head["Content-Encoding"] = "deflate"
19
- # send it back deflated
20
- out << Zlib::Deflate.deflate(results)
21
- else
22
- # no gzip supported, send it back normal
23
- out << results
24
- end
25
- end
26
- end
27
- end
28
-
29
- class MongrelDaemon < Win32::Daemon
30
- def initialize(options)
31
- @options = options
32
- end
33
-
34
- def service_init
35
- File.open(DEBUG_LOG_FILE,"a+") { |f| f.puts("#{Time.now} - service_init entered") }
36
-
37
- File.open(DEBUG_LOG_FILE,"a+") { |f| f.puts("Mongrel running on #{@options[:ip]}:#{@options[:port]} with docroot #{@options[:server_root]}") }
38
-
39
- @simple = SimpleHandler.new
40
- @files = Mongrel::DirHandler.new(@options[:server_root])
41
-
42
- @http_server = Mongrel::HttpServer.new(@options[:ip], @options[:port])
43
- @http_server.register("/", @simple)
44
- @http_server.register("/files", @files)
45
-
46
- File.open(DEBUG_LOG_FILE,"a+") { |f| f.puts("#{Time.now} - service_init left") }
47
- end
48
-
49
- def service_stop
50
- File.open(DEBUG_LOG_FILE,"a+"){ |f|
51
- f.puts "stop signal received: " + Time.now.to_s
52
- f.puts "sending stop to mongrel threads: " + Time.now.to_s
53
- }
54
- #@http_server.stop
55
- end
56
-
57
- def service_pause
58
- File.open(DEBUG_LOG_FILE,"a+"){ |f|
59
- f.puts "pause signal received: " + Time.now.to_s
60
- }
61
- end
62
-
63
- def service_resume
64
- File.open(DEBUG_LOG_FILE,"a+"){ |f|
65
- f.puts "continue/resume signal received: " + Time.now.to_s
66
- }
67
- end
68
-
69
- def service_main
70
- File.open(DEBUG_LOG_FILE,"a+") { |f| f.puts("#{Time.now} - service_main entered") }
71
-
72
- begin
73
- File.open(DEBUG_LOG_FILE,"a+") { |f| f.puts("#{Time.now} - http_server.run") }
74
- @http_server.run
75
-
76
- # No runner thread was needed after all!
77
- #@runner = Thread.new do
78
- # @http_server.acceptor.join
79
- #end
80
- #File.open("d:\\test.log","a+") { |f| f.puts("#{Time.now} - runner.run") }
81
- #@runner.run
82
-
83
- # here is where magic happens!
84
- # if put blocking code here, the thread never left service_main, and the rb_func_call in service.c
85
- # never exit, even if the stop signal is received.
86
- #
87
- # to probe my theory, just comment the while loop and remove the '1' from sleep function
88
- # service start ok, but fail to stop.
89
- #
90
- # Even if no functional code is in service_main (because we have other working threads),
91
- # we must monitor the state of the service to exit when the STOP event is received.
92
- #
93
- # Note: maybe not loop in 1 second intervals?
94
- while state == RUNNING
95
- sleep 1
96
- end
97
-
98
- rescue StandardError, Exception, interrupt => err
99
- File.open(DEBUG_LOG_FILE,"a+"){ |f| f.puts("#{Time.now} - Error: #{err}") }
100
- File.open(DEBUG_LOG_FILE,"a+"){ |f| f.puts("BACKTRACE: " + err.backtrace.join("\n")) }
101
-
102
- end
103
-
104
- File.open(DEBUG_LOG_FILE,"a+") { |f| f.puts("#{Time.now} - service_main left") }
105
- end
106
-
107
- end
108
-
109
- OPTIONS = {
110
- :port => 3000,
111
- :ip => "0.0.0.0",
112
- :server_root => File.expand_path(File.dirname(__FILE__)),
113
- }
114
-
115
- web_server = MongrelDaemon.new(OPTIONS)
116
- web_server.mainloop