thin 1.2.3-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of thin might be problematic. Click here for more details.

Files changed (137) hide show
  1. data/CHANGELOG +263 -0
  2. data/COPYING +18 -0
  3. data/README +69 -0
  4. data/Rakefile +36 -0
  5. data/benchmark/abc +51 -0
  6. data/benchmark/benchmarker.rb +80 -0
  7. data/benchmark/runner +82 -0
  8. data/bin/thin +6 -0
  9. data/example/adapter.rb +32 -0
  10. data/example/async_app.ru +126 -0
  11. data/example/async_chat.ru +247 -0
  12. data/example/async_tailer.ru +100 -0
  13. data/example/config.ru +22 -0
  14. data/example/monit_sockets +20 -0
  15. data/example/monit_unixsock +20 -0
  16. data/example/myapp.rb +1 -0
  17. data/example/ramaze.ru +12 -0
  18. data/example/thin.god +80 -0
  19. data/example/thin_solaris_smf.erb +36 -0
  20. data/example/thin_solaris_smf.readme.txt +150 -0
  21. data/example/vlad.rake +64 -0
  22. data/ext/thin_parser/common.rl +55 -0
  23. data/ext/thin_parser/ext_help.h +14 -0
  24. data/ext/thin_parser/extconf.rb +6 -0
  25. data/ext/thin_parser/parser.c +452 -0
  26. data/ext/thin_parser/parser.h +49 -0
  27. data/ext/thin_parser/parser.rl +157 -0
  28. data/ext/thin_parser/thin.c +433 -0
  29. data/lib/rack/adapter/loader.rb +79 -0
  30. data/lib/rack/adapter/rails.rb +181 -0
  31. data/lib/thin.rb +46 -0
  32. data/lib/thin/backends/base.rb +141 -0
  33. data/lib/thin/backends/swiftiply_client.rb +56 -0
  34. data/lib/thin/backends/tcp_server.rb +29 -0
  35. data/lib/thin/backends/unix_server.rb +51 -0
  36. data/lib/thin/command.rb +53 -0
  37. data/lib/thin/connection.rb +222 -0
  38. data/lib/thin/controllers/cluster.rb +127 -0
  39. data/lib/thin/controllers/controller.rb +183 -0
  40. data/lib/thin/controllers/service.rb +75 -0
  41. data/lib/thin/controllers/service.sh.erb +39 -0
  42. data/lib/thin/daemonizing.rb +174 -0
  43. data/lib/thin/headers.rb +39 -0
  44. data/lib/thin/logging.rb +54 -0
  45. data/lib/thin/request.rb +153 -0
  46. data/lib/thin/response.rb +101 -0
  47. data/lib/thin/runner.rb +209 -0
  48. data/lib/thin/server.rb +247 -0
  49. data/lib/thin/stats.html.erb +216 -0
  50. data/lib/thin/stats.rb +52 -0
  51. data/lib/thin/statuses.rb +43 -0
  52. data/lib/thin/version.rb +32 -0
  53. data/lib/thin_parser.so +0 -0
  54. data/spec/backends/swiftiply_client_spec.rb +66 -0
  55. data/spec/backends/tcp_server_spec.rb +33 -0
  56. data/spec/backends/unix_server_spec.rb +37 -0
  57. data/spec/command_spec.rb +25 -0
  58. data/spec/configs/cluster.yml +9 -0
  59. data/spec/configs/single.yml +9 -0
  60. data/spec/connection_spec.rb +106 -0
  61. data/spec/controllers/cluster_spec.rb +235 -0
  62. data/spec/controllers/controller_spec.rb +129 -0
  63. data/spec/controllers/service_spec.rb +50 -0
  64. data/spec/daemonizing_spec.rb +192 -0
  65. data/spec/headers_spec.rb +40 -0
  66. data/spec/logging_spec.rb +46 -0
  67. data/spec/perf/request_perf_spec.rb +50 -0
  68. data/spec/perf/response_perf_spec.rb +19 -0
  69. data/spec/perf/server_perf_spec.rb +39 -0
  70. data/spec/rack/loader_spec.rb +29 -0
  71. data/spec/rack/rails_adapter_spec.rb +106 -0
  72. data/spec/rails_app/app/controllers/application.rb +10 -0
  73. data/spec/rails_app/app/controllers/simple_controller.rb +19 -0
  74. data/spec/rails_app/app/helpers/application_helper.rb +3 -0
  75. data/spec/rails_app/app/views/simple/index.html.erb +15 -0
  76. data/spec/rails_app/config/boot.rb +109 -0
  77. data/spec/rails_app/config/environment.rb +64 -0
  78. data/spec/rails_app/config/environments/development.rb +18 -0
  79. data/spec/rails_app/config/environments/production.rb +19 -0
  80. data/spec/rails_app/config/environments/test.rb +22 -0
  81. data/spec/rails_app/config/initializers/inflections.rb +10 -0
  82. data/spec/rails_app/config/initializers/mime_types.rb +5 -0
  83. data/spec/rails_app/config/routes.rb +35 -0
  84. data/spec/rails_app/public/404.html +30 -0
  85. data/spec/rails_app/public/422.html +30 -0
  86. data/spec/rails_app/public/500.html +30 -0
  87. data/spec/rails_app/public/dispatch.cgi +10 -0
  88. data/spec/rails_app/public/dispatch.fcgi +24 -0
  89. data/spec/rails_app/public/dispatch.rb +10 -0
  90. data/spec/rails_app/public/favicon.ico +0 -0
  91. data/spec/rails_app/public/images/rails.png +0 -0
  92. data/spec/rails_app/public/index.html +277 -0
  93. data/spec/rails_app/public/javascripts/application.js +2 -0
  94. data/spec/rails_app/public/javascripts/controls.js +963 -0
  95. data/spec/rails_app/public/javascripts/dragdrop.js +972 -0
  96. data/spec/rails_app/public/javascripts/effects.js +1120 -0
  97. data/spec/rails_app/public/javascripts/prototype.js +4225 -0
  98. data/spec/rails_app/public/robots.txt +5 -0
  99. data/spec/rails_app/script/about +3 -0
  100. data/spec/rails_app/script/console +3 -0
  101. data/spec/rails_app/script/destroy +3 -0
  102. data/spec/rails_app/script/generate +3 -0
  103. data/spec/rails_app/script/performance/benchmarker +3 -0
  104. data/spec/rails_app/script/performance/profiler +3 -0
  105. data/spec/rails_app/script/performance/request +3 -0
  106. data/spec/rails_app/script/plugin +3 -0
  107. data/spec/rails_app/script/process/inspector +3 -0
  108. data/spec/rails_app/script/process/reaper +3 -0
  109. data/spec/rails_app/script/process/spawner +3 -0
  110. data/spec/rails_app/script/runner +3 -0
  111. data/spec/rails_app/script/server +3 -0
  112. data/spec/request/mongrel_spec.rb +39 -0
  113. data/spec/request/parser_spec.rb +215 -0
  114. data/spec/request/persistent_spec.rb +35 -0
  115. data/spec/request/processing_spec.rb +45 -0
  116. data/spec/response_spec.rb +91 -0
  117. data/spec/runner_spec.rb +168 -0
  118. data/spec/server/builder_spec.rb +44 -0
  119. data/spec/server/pipelining_spec.rb +110 -0
  120. data/spec/server/robustness_spec.rb +34 -0
  121. data/spec/server/stopping_spec.rb +55 -0
  122. data/spec/server/swiftiply.yml +6 -0
  123. data/spec/server/swiftiply_spec.rb +32 -0
  124. data/spec/server/tcp_spec.rb +57 -0
  125. data/spec/server/threaded_spec.rb +27 -0
  126. data/spec/server/unix_socket_spec.rb +26 -0
  127. data/spec/server_spec.rb +96 -0
  128. data/spec/spec_helper.rb +219 -0
  129. data/tasks/announce.rake +22 -0
  130. data/tasks/deploy.rake +13 -0
  131. data/tasks/email.erb +30 -0
  132. data/tasks/gem.rake +74 -0
  133. data/tasks/rdoc.rake +25 -0
  134. data/tasks/site.rake +15 -0
  135. data/tasks/spec.rake +49 -0
  136. data/tasks/stats.rake +28 -0
  137. metadata +246 -0
@@ -0,0 +1,263 @@
1
+ == 1.2.3
2
+ * Fix a few issues in thin to make it a better "gem citizen" [josh]
3
+ * Fix test for rack based Rails in adapter under Ruby >= 1.8.7 [#109 state:resolved]
4
+ * Fix Remote address spoofing vulnerability in Connection#remote_address [Alexey Borzenkov]
5
+ * Fix uninitialized constant ActionController::Dispatcher error with Rails 1.2.3 [Chris Anderton] [#103 state:resolved]
6
+
7
+ == 1.2.2 I Find Your Lack of Sauce Disturbing release
8
+ * Fix force kill under 1.9 [Alexey Chebotar]
9
+ * Fix regression when --only option is used w/ --socket.
10
+ * Add process name 'tag' functionality. Easier to distinguish thin daemons
11
+ from eachother in process listing [ctcherry]
12
+
13
+ == 1.2.1 Asynctilicious Ultra Supreme release
14
+ * Require Rack 1.0.0
15
+ * Require EventMachine 0.12.6
16
+ * Use Rails Rack based dispatcher when available
17
+ * Allow String for response body
18
+ * Require openssl before eventmachine to prevent crash in 1.9
19
+
20
+ == 1.2.0 Asynctilicious Supreme release
21
+ * Add support for Windows mingw Ruby distro [Juan C. Rodriguez]
22
+ * Add async response support, see example/async_*.ru [raggi]
23
+
24
+ == 1.1.1 Super Disco Power Plus release
25
+ * Fix bug when running with only options [hasimo]
26
+
27
+ == 1.1.0 Super Disco Power release
28
+ * Require EventMachine 0.12.4
29
+ * Remove Thin handler, now part of Rack 0.9.1
30
+ * Fix Rack protocol version to 0.1 in environment hash.
31
+ * Fix error when passing no_epoll option to a cluster.
32
+ * Omit parsing #defined strings [Jérémy Zurcher]
33
+ * Defaults SERVER_NAME to localhost like webrick does [#87 state:resolved]
34
+ * Namespace parser to prevent error when mongrel is required [cliffmoon]
35
+ * Set RACK_ENV based on environment option when loading rackup file [Curtis Summers] [#83 state:resolved]
36
+ * Fixes a warning RE relative_url_root when using a prefix with Rails 2.1.1 [seriph] [#85 state:resolved]
37
+ * --only can work as a sequence number (if < 80) or a port number (if >= 80) [jmay] [#81 state:resolved]
38
+
39
+ == 1.0.0 That's What She Said release
40
+ * Fixed vlad.rake to allow TCP or socket [hellekin]
41
+ * Updated Mack adapter to handle both <0.8.0 and >0.8.0 [Mark Bates]
42
+ * rails rack adapter uses File.readable_real? so it recognizes ACL permissions [Ricardo Chimal]
43
+ * Log a warning if Rack application returns nil body [Michael S. Klishin]
44
+ * Handle nil and Time header values correctly [#76 state:resolved] [tmm1]
45
+ * Add Content-Length header to response automatically when possible [#74 state:resolved] [dkubb]
46
+ * Runner now remembers -r, -D and -V parameters so that clustered servers inherit those and
47
+ `restart` keep your parameters.
48
+ * Make Set-Cookie header, in Rails adapter, compatible with current Rack spec [Pedro Belo]
49
+ [#73, state:resolved]
50
+ * Add --no-epoll option to disable epoll usage on Linux [#61 state:resolved]
51
+ * Add --force (-f) option to force stopping of a daemonized server [#72 state:resolved]
52
+ * Update halycon adapter loader [mtodd]
53
+
54
+ == 0.8.2 Double Margarita release
55
+ * Require EventMachine 0.12.0
56
+ * [bug] Fix timeout handling when running command
57
+ * [bug] Fix hanging when restarting and no process is running in single server move, fixes #67
58
+ * Added Mack adapter [markbates]
59
+ * Allow rackup .rb files by getting a conventionally named constant as the app [bmizerany]
60
+
61
+ == 0.8.1 Rebel Porpoise release
62
+ * [bug] Rescue all types of errors when processing request, fixes #62
63
+ * [bug] Use Swiftiply backend when -y option is specified, fixes #63 and #64
64
+ * Allow passing port as a string in Server.new
65
+ * Define deferred?(env) in your Rack application to set if a request is handled in a
66
+ thread (return true) or not (return false).
67
+
68
+ == 0.8.0 Dodgy Dentist release
69
+ * [bug] Fix server crash when header too large.
70
+ * Add --require (-r) option to require a library, before executing your script.
71
+ * Rename --rackup short option to -R, warn and load as rackup when file ends with .ru.
72
+ * List supported adapters in command usage.
73
+ * Add file adapter to built-in adapter, serve static files in current directory.
74
+ * Allow disabling signal handling in Server with :signals => false
75
+ * Make Server.new arguments more flexible, can now specify any of host, port, app or hash options.
76
+ * Add --backend option to specified which backend to use, closes #55
77
+ * [bug] Serve static file only on GET and HEAD requests in Rails adapter, fixes #58
78
+ * Add threaded option to run server in threaded mode, calling the application in a
79
+ thread allowing for concurrency in the Rack adapter, closes #46
80
+ * Guess which adapter to use from directory (chdir option)
81
+ or use specified one in 'adapter' option, re #47.
82
+
83
+ == 0.7.1 Fancy Pants release
84
+ * Clean stale PID files when starting as daemon, fixes #53 [Chu Yeow]
85
+ * Require EventMachine 0.11.0 for UNIX domain sockets. Until it's released, install from:
86
+ gem install eventmachine --source http://code.macournoyer.com
87
+ * Ruby 1.8.5 compatibility, closes #49 [Wincent Colaiuta]
88
+ * Move all EventMachine stuff out of Server, you can now create a Thin Backend that
89
+ does not depend on EventMachine.
90
+ * Rename Connector to Backend. Extend Thin::Backends::Base to implement your own.
91
+ * Fix high memory usage with big POST body, fixes #48
92
+
93
+ == 0.7.0 Spherical Cow release
94
+ * Add --max-persistent-conns option to sets the maximum number of persistent connections.
95
+ Set to 0 to disable Keep-Alive.
96
+ * INT signal now force stop and QUIT signal gracefully stops.
97
+ * Warn when descriptors table size can't be set as high as expected.
98
+ * Eval Rackup config file using top level bindings.
99
+ * Remove daemons gem dependency on Windows plateform, fixes #45.
100
+ * Change default timeout from 60 to 30 seconds.
101
+ * Add --max-conns option to sets the maximum number of file or socket descriptors that
102
+ your process may open, defaults to 1024.
103
+ * Tail logfile when stopping and restarting a demonized server, fixes #26.
104
+ * Wrap application in a Rack::CommonLogger adapter in debug mode.
105
+ * --debug (-D) option no longer set $DEBUG so logging will be less verbose
106
+ and Ruby won't be too strict, fixes #36.
107
+ * Deprecate Server#silent in favour of Logging.silent.
108
+ * Persistent connection (keep-alive) support.
109
+ * Fix -s option not being included in generated config file, fixes #37.
110
+ * Add Swiftiply support. Use w/ the --swiftiply (-y) option in the thin script,
111
+ closes #28 [Alex MacCaw]
112
+
113
+ == 0.6.4 Sexy Lobster release
114
+ * Fix error when stopping server on UNIX domain socket, fixes #42
115
+ * Rescue errors in Connection#get_peername more gracefully, setting REMOTE_ADDR to nil, fixes #43
116
+
117
+ == 0.6.3 Ninja Cookie release
118
+ * Add tasks for Vlad the Deployer in example/vlad.rake [cnantais]
119
+ * Add Ramaze Rackup config file in example dir [tmm1]
120
+ Use like this from you Ramaze app dir:
121
+
122
+ thin start -r /path/to/thin/example/ramaze.ru
123
+
124
+ * Add the --rackup option to load a Rack config file instead of the Rails adapter.
125
+ So you can use any framework with the thin script and start cluster and stuff like that.
126
+ A Rack config file is one that is usable through the rackup command and looks like this:
127
+
128
+ use Rack::CommonLogger
129
+ run MyCrazyRackAdapter.new(:uterly, 'cool')
130
+
131
+ Then use it with thin like this:
132
+
133
+ thin start --rackup config.ru
134
+
135
+ * thin config --chrdir ... -C thin/yml do not change current directory anymore, fixes #33.
136
+ * Add a better sample god config file in example/thin.god that loads all info from config
137
+ files in /etc/thin. Drop-in replacement for the thin runlevel service [Gump].
138
+ * Add support for specifying a custom Connector to the server and add more doc about Server
139
+ configuration.
140
+ * Add a script to run thin as a runlevel service that can start at startup, closes #31 [Gump]
141
+ Setup the service like this:
142
+
143
+ sudo thin install /etc/thin
144
+
145
+ This will install the boot script under /etc/init.d/thin. Then copy your config files to
146
+ /etc/thin. Works only under Linux.
147
+ * Set process name to 'thin server (0.0.0.0:3000)' when running as a daemon, closes #32.
148
+ * Make sure chdir option from config file is used when present.
149
+ * Raise an error when starting a server as a daemon and pid file already exist, fixes #27.
150
+
151
+ == 0.6.2 Rambo release
152
+ * Server now let current connections finish before stopping, fixes #18
153
+ * Fix uploading hanging bug when body is moved to a tempfile,
154
+ also delete the tempfile properly upon completion, fixes #25
155
+ * 'thin restart' now sends HUP signals rather then stopping & starting, closes #17
156
+ * HUP signal now launches a new process with the same options.
157
+ * Add PID and more info from the last request to the Stats adapter
158
+ mostly taken from Rack::ShowException.
159
+ * pid and log files in cluster are no longer required to be relative to the
160
+ app directory (chdir option), fixes #24
161
+ * Revert to using #each when building response headers under Ruby 1.8,
162
+ solves an issue w/ Camping adapter, fixes #22
163
+ * Restructure thin script options in 3 sections: server, daemon and cluster
164
+ * Add --only (-o) option to control only one server of a cluster.
165
+ * Stylize stats page and make the url configurable from the thin script.
166
+ * Raise error if attempting to use unix sockets on windows.
167
+ * Add example config files for http://www.tildeslash.com/monit usage.
168
+ Include the example file using "include /path/to/thin/monit/file" in your monitrc file.
169
+ The group settings let you do this to manage your clusters:
170
+
171
+ sudo monit -g blog restart all
172
+
173
+ There are examples of thin listening on sockets and thin listening on unix sockets.
174
+
175
+ == 0.6.1 Cheesecake release
176
+ * Remove socket file when server stops.
177
+ * Set back cluster to use 'thin' command to launch servers.
178
+
179
+ == 0.6.0 Big Pony release
180
+ * Add support for connection through UNIX domain socket.
181
+ Use the --socket (-S) option w/ the thin script to configure the socket filename.
182
+ Nginx support binding to a UNIX socket like this:
183
+
184
+ upstream backend {
185
+ server unix:/tmp/thin.0.sock;
186
+ server unix:/tmp/thin.1.sock;
187
+ server unix:/tmp/thin.2.sock;
188
+ }
189
+
190
+ Start your servers like this:
191
+
192
+ thin start -s3 -S/tmp/thin.sock
193
+
194
+ * Remove Server#listen! method. Use Server#start instead.
195
+ * Server can now yield a Rack::Builder to allow building an app in one call:
196
+
197
+ Server.start '0.0.0.0', 3000 do
198
+ use Rack::CommonLogger
199
+ use Rack::ShowExceptions
200
+ map "/lobster" do
201
+ use Rack::Lint
202
+ run Rack::Lobster.new
203
+ end
204
+ end
205
+
206
+ * Add a very basic stats page through Stats adapter, load w/ --stats and browse to /stats.
207
+ * Add --trace (-V) option to trace request/response and get backtrace w/out all Ruby debug stuff.
208
+ * Add --config (-C) option to load options from a config file in thin script [Matt Todd].
209
+ * Alter response headers to output directly to a string.
210
+ * Improve specs stability.
211
+ * Move request body to a Tempfile if too big (> 112 MB)
212
+ * Remove useless check for max header size in Request (already done in the parser)
213
+
214
+ == 0.5.4 Flying Mustard release
215
+ * Don't read the full body, use direct streaming when sending response.
216
+ See: Response#each
217
+ As a result, the Content-Length can not be calculated anymore.
218
+ You have to do set this in your adapter. All frameworks do it anyway.
219
+ It improve memory usage and boost speed for low concurrency.
220
+ Thanks to Kent Sibilev and Ezra for their help on that one.
221
+ * Add 'Server' response header
222
+ * Fix --user and --group option not changing daemon process privileges
223
+
224
+ == 0.5.3 Purple Yogurt release
225
+ * win32 pre-compiled gem now available
226
+ * change rake task configuration to allow win32 gem build
227
+ * Add prefix option to thin script to mount app under a given path.
228
+
229
+ == 0.5.2 Cheezburger release
230
+ * Add cluster support through the -s option in the thin script, start 3 thins like this:
231
+ thin start -s3 -p3000
232
+ 3 thin servers will be started on port 3000, 3001, 3002, also the port number will be
233
+ injected in the pid and log filenames.
234
+ * Fix IOError when writing to logger when starting server as a daemon.
235
+ * Really change directory when the -c option is specified.
236
+ * Add restart command to thin script.
237
+ * Fix typos in thin script usage message and expand chdir path.
238
+ * Rename thin script options to be the same as mongrel_rails script [thronedrk]:
239
+ -o --host => -a --address
240
+ --log-file => --log
241
+ --pid-file => --pid
242
+ --env => --environment
243
+
244
+ == 0.5.1 LOLCAT release
245
+ * Add URL rewriting to Rails adapter so that page caching works and / fetches index.html if present.
246
+ * Fix bug in multiline response header parsing.
247
+ * Add specs for the Rails adapter.
248
+ * Fix Set-Cookie headers in Rails adapter to handle multiple values correctly.
249
+ * Fix Ruby 1.9 incompatibility in Response#headers= and Rakefile.
250
+ * Fix parser to be Ruby 1.9 compatible [Aman Gupta]
251
+ * Set gemspec to use EventMachine version 0.8.1 as it's the latest one having precompiled windows binaries.
252
+ [Francis Cianfrocca].
253
+ * Add -D option to thin script to set debugging on.
254
+ * Output incoming data and response when debugging is on.
255
+
256
+ == 0.5.0
257
+ * Full rewrite to use EventMachine, Rack and Mongrel parser
258
+
259
+ == 0.4.1
260
+ * Fix Rails environment option not being used in thin script.
261
+
262
+ == 0.4.0
263
+ * First alphaish release as a gem.
data/COPYING ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2008 Marc-Andre Cournoyer
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to
5
+ deal in the Software without restriction, including without limitation the
6
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ sell copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,69 @@
1
+ == Thin
2
+ Tiny, fast & funny HTTP server
3
+
4
+ Thin is a Ruby web server that glues together 3 of the best Ruby libraries in web history:
5
+ * the Mongrel parser: the root of Mongrel speed and security
6
+ * Event Machine: a network I/O library with extremely high scalability, performance and stability
7
+ * Rack: a minimal interface between webservers and Ruby frameworks
8
+
9
+ Which makes it, with all humility, the most secure, stable, fast and extensible Ruby web server
10
+ bundled in an easy to use gem for your own pleasure.
11
+
12
+ Site: http://code.macournoyer.com/thin/
13
+ Group: http://groups.google.com/group/thin-ruby/topics
14
+ Bugs: http://thin.lighthouseapp.com/projects/7212-thin
15
+ Code: http://github.com/macournoyer/thin
16
+ IRC: #thin on freenode
17
+
18
+ === Installation
19
+ For the latest stable version:
20
+
21
+ sudo gem install thin
22
+
23
+ Or from source:
24
+
25
+ git clone git://github.com/macournoyer/thin.git
26
+ cd thin
27
+ rake install
28
+
29
+ === Usage
30
+ A +thin+ script offers an easy way to start your Rails application:
31
+
32
+ cd to/your/rails/app
33
+ thin start
34
+
35
+ But Thin is also usable with a Rack config file.
36
+ You need to setup a config.ru file and pass it to the thin script:
37
+
38
+ cat config.ru
39
+ app = proc do |env|
40
+ [
41
+ 200,
42
+ {
43
+ 'Content-Type' => 'text/html',
44
+ 'Content-Length' => '2'
45
+ },
46
+ ['hi']
47
+ ]
48
+ end
49
+
50
+ run app
51
+
52
+ thin start -R config.ru
53
+
54
+ See example directory for more samples and run 'thin -h' for usage.
55
+
56
+ === License
57
+ Ruby License, http://www.ruby-lang.org/en/LICENSE.txt.
58
+
59
+ === Credits
60
+ The parser was stolen from Mongrel http://mongrel.rubyforge.org by Zed Shaw.
61
+ Mongrel Web Server (Mongrel) is copyrighted free software by Zed A. Shaw
62
+ <zedshaw at zedshaw dot com> You can redistribute it and/or modify it under
63
+ either the terms of the GPL.
64
+
65
+ Thin is copyright Marc-Andre Cournoyer <macournoyer@gmail.com>
66
+
67
+ Get help at http://groups.google.com/group/thin-ruby/
68
+ Report bugs at http://thin.lighthouseapp.com/projects/7212-thin
69
+ and major security issues directly to a team member (see COMMITTERS)
@@ -0,0 +1,36 @@
1
+ RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
2
+ WIN = (RUBY_PLATFORM =~ /mswin|cygwin/)
3
+ SUDO = (WIN ? "" : "sudo")
4
+
5
+ require 'rake'
6
+ require 'rake/clean'
7
+ require 'rake/extensiontask' # from rake-compiler gem
8
+
9
+ $: << File.join(File.dirname(__FILE__), 'lib')
10
+ require 'thin'
11
+
12
+ # Load tasks in tasks/
13
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
14
+
15
+ task :default => :spec
16
+
17
+ Rake::ExtensionTask.new('thin_parser', Thin::GemSpec) do |ext|
18
+ ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
19
+ ext.cross_platform = 'i386-mswin32' # forces the Windows platform instead of the default one
20
+ # configure options only for cross compile
21
+ end
22
+
23
+ CLEAN.include %w(**/*.{o,bundle,jar,so,obj,pdb,lib,def,exp,log} ext/*/Makefile ext/*/conftest.dSYM)
24
+
25
+ desc "Compile the Ragel state machines"
26
+ task :ragel do
27
+ Dir.chdir 'ext/thin_parser' do
28
+ target = "parser.c"
29
+ File.unlink target if File.exist? target
30
+ sh "ragel parser.rl | rlgen-cd -G2 -o #{target}"
31
+ raise "Failed to compile Ragel state machine" unless File.exist? target
32
+ end
33
+ end
34
+
35
+ desc "Release version #{Thin::VERSION::STRING} gems to rubyforge"
36
+ task :release => [:clean, :cross, :native, :gem, :tag, "gem:upload"]
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env ruby
2
+ # Automate benchmarking with ab with various concurrency levels.
3
+ require 'optparse'
4
+
5
+ options = {
6
+ :address => '0.0.0.0',
7
+ :port => 3000,
8
+ :requests => 1000,
9
+ :start => 1,
10
+ :end => 100,
11
+ :step => 10
12
+ }
13
+
14
+ OptionParser.new do |opts|
15
+ opts.banner = "Usage: #{$PROGRAM_NAME} [options]"
16
+
17
+ opts.on("-n", "--requests NUM", "Number of requests") { |num| options[:requests] = num }
18
+ opts.on("-a", "--address HOST", "Address (default: 0.0.0.0)") { |host| options[:address] = host }
19
+ opts.on("-p", "--port PORT", "use PORT (default: 3000)") { |port| options[:port] = port.to_i }
20
+ opts.on("-s", "--start N", "First concurrency level") { |n| options[:start] = n.to_i }
21
+ opts.on("-e", "--end N", "Last concurrency level") { |n| options[:end] = n.to_i }
22
+ opts.on("-S", "--step N", "Concurrency level step") { |n| options[:step] = n.to_i }
23
+ opts.on("-u", "--uri PATH", "Path to send to") { |u| options[:uri] = u }
24
+ opts.on("-k", "--keep-alive", "Use Keep-Alive") { options[:keep_alive] = true }
25
+
26
+ opts.on_tail("-h", "--help", "Show this message") { puts opts; exit }
27
+ end.parse!(ARGV)
28
+
29
+ puts 'request concurrency req/s failures'
30
+ puts '=' * 42
31
+
32
+ c = options[:start]
33
+ until c >= options[:end]
34
+ sleep 0.5
35
+ out = `nice -n20 ab #{'-k' if options[:keep_alive]} -c #{c} -n #{options[:requests]} #{options[:address]}:#{options[:port]}/#{options[:uri]} 2> /dev/null`
36
+
37
+ r = if requests = out.match(/^Requests.+?(\d+\.\d+)/)
38
+ requests[1].to_i
39
+ else
40
+ 0
41
+ end
42
+ f = if requests = out.match(/^Failed requests.+?(\d+)/)
43
+ requests[1].to_i
44
+ else
45
+ 0
46
+ end
47
+
48
+ puts "#{options[:requests].to_s.ljust(9)} #{c.to_s.ljust(13)} #{r.to_s.ljust(8)} #{f}"
49
+
50
+ c += options[:step]
51
+ end
@@ -0,0 +1,80 @@
1
+ require 'rack/lobster'
2
+
3
+ class Benchmarker
4
+ PORT = 7000
5
+ ADDRESS = '0.0.0.0'
6
+
7
+ attr_accessor :requests, :concurrencies, :servers, :keep_alive
8
+
9
+ def initialize
10
+ @servers = %w(Mongrel EMongrel Thin)
11
+ @requests = 1000
12
+ @concurrencies = [1, 10, 100]
13
+ end
14
+
15
+ def writer(&block)
16
+ @writer = block
17
+ end
18
+
19
+ def run!
20
+ @concurrencies.each do |concurrency|
21
+ @servers.each do |server|
22
+ req_sec, failed = run_one(server, concurrency)
23
+ @writer.call(server, @requests, concurrency, req_sec, failed)
24
+ end
25
+ end
26
+ end
27
+
28
+ private
29
+ def start_server(handler_name)
30
+ @server = fork do
31
+ [STDOUT, STDERR].each { |o| o.reopen "/dev/null" }
32
+
33
+ case handler_name
34
+ when 'EMongrel'
35
+ require 'swiftcore/evented_mongrel'
36
+ handler_name = 'Mongrel'
37
+ end
38
+
39
+ app = proc do |env|
40
+ [200, {'Content-Type' => 'text/html', 'Content-Length' => '11'}, ['hello world']]
41
+ end
42
+
43
+ handler = Rack::Handler.const_get(handler_name)
44
+ handler.run app, :Host => ADDRESS, :Port => PORT
45
+ end
46
+
47
+ sleep 2
48
+ end
49
+
50
+ def stop_server
51
+ Process.kill('SIGKILL', @server)
52
+ Process.wait
53
+ end
54
+
55
+ def run_ab(concurrency)
56
+ `nice -n20 ab -c #{concurrency} -n #{@requests} #{@keep_alive ? '-k' : ''} #{ADDRESS}:#{PORT}/ 2> /dev/null`
57
+ end
58
+
59
+ def run_one(handler_name, concurrency)
60
+ start_server(handler_name)
61
+
62
+ out = run_ab(concurrency)
63
+
64
+ stop_server
65
+
66
+ req_sec = if matches = out.match(/^Requests.+?(\d+\.\d+)/)
67
+ matches[1].to_i
68
+ else
69
+ 0
70
+ end
71
+
72
+ failed = if matches = out.match(/^Failed requests.+?(\d+)/)
73
+ matches[1].to_i
74
+ else
75
+ 0
76
+ end
77
+
78
+ [req_sec, failed]
79
+ end
80
+ end