friendlyfashion-thin 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/CHANGELOG +346 -0
  2. data/README.md +64 -0
  3. data/Rakefile +24 -0
  4. data/bin/thin +6 -0
  5. data/example/adapter.rb +32 -0
  6. data/example/async_app.ru +126 -0
  7. data/example/async_chat.ru +247 -0
  8. data/example/async_tailer.ru +100 -0
  9. data/example/config.ru +22 -0
  10. data/example/monit_sockets +20 -0
  11. data/example/monit_unixsock +20 -0
  12. data/example/myapp.rb +1 -0
  13. data/example/ramaze.ru +12 -0
  14. data/example/thin.god +80 -0
  15. data/example/thin_solaris_smf.erb +36 -0
  16. data/example/thin_solaris_smf.readme.txt +150 -0
  17. data/example/vlad.rake +64 -0
  18. data/ext/thin_parser/common.rl +55 -0
  19. data/ext/thin_parser/ext_help.h +14 -0
  20. data/ext/thin_parser/extconf.rb +6 -0
  21. data/ext/thin_parser/parser.c +1249 -0
  22. data/ext/thin_parser/parser.h +49 -0
  23. data/ext/thin_parser/parser.rl +157 -0
  24. data/ext/thin_parser/thin.c +436 -0
  25. data/lib/rack/adapter/loader.rb +75 -0
  26. data/lib/rack/adapter/rails.rb +183 -0
  27. data/lib/thin.rb +45 -0
  28. data/lib/thin/backends/base.rb +151 -0
  29. data/lib/thin/backends/swiftiply_client.rb +56 -0
  30. data/lib/thin/backends/tcp_server.rb +29 -0
  31. data/lib/thin/backends/unix_server.rb +56 -0
  32. data/lib/thin/command.rb +53 -0
  33. data/lib/thin/connection.rb +201 -0
  34. data/lib/thin/controllers/cluster.rb +178 -0
  35. data/lib/thin/controllers/controller.rb +188 -0
  36. data/lib/thin/controllers/service.rb +75 -0
  37. data/lib/thin/controllers/service.sh.erb +39 -0
  38. data/lib/thin/daemonizing.rb +185 -0
  39. data/lib/thin/headers.rb +39 -0
  40. data/lib/thin/logging.rb +54 -0
  41. data/lib/thin/request.rb +156 -0
  42. data/lib/thin/response.rb +104 -0
  43. data/lib/thin/runner.rb +222 -0
  44. data/lib/thin/server.rb +270 -0
  45. data/lib/thin/stats.html.erb +216 -0
  46. data/lib/thin/stats.rb +52 -0
  47. data/lib/thin/statuses.rb +43 -0
  48. data/lib/thin/version.rb +32 -0
  49. metadata +151 -0
data/lib/thin/stats.rb ADDED
@@ -0,0 +1,52 @@
1
+ require 'erb'
2
+
3
+ module Thin
4
+ module Stats
5
+ # Rack adapter to log stats about a Rack application.
6
+ class Adapter
7
+ include ERB::Util
8
+
9
+ def initialize(app, path='/stats')
10
+ @app = app
11
+ @path = path
12
+
13
+ @template = ERB.new(File.read(File.dirname(__FILE__) + '/stats.html.erb'))
14
+
15
+ @requests = 0
16
+ @requests_finished = 0
17
+ @start_time = Time.now
18
+ end
19
+
20
+ def call(env)
21
+ if env['PATH_INFO'].index(@path) == 0
22
+ serve(env)
23
+ else
24
+ log(env) { @app.call(env) }
25
+ end
26
+ end
27
+
28
+ def log(env)
29
+ @requests += 1
30
+ @last_request = Rack::Request.new(env)
31
+ request_started_at = Time.now
32
+
33
+ response = yield
34
+
35
+ @requests_finished += 1
36
+ @last_request_time = Time.now - request_started_at
37
+
38
+ response
39
+ end
40
+
41
+ def serve(env)
42
+ body = @template.result(binding)
43
+
44
+ [
45
+ 200,
46
+ { 'Content-Type' => 'text/html' },
47
+ [body]
48
+ ]
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,43 @@
1
+ module Thin
2
+ # Every standard HTTP code mapped to the appropriate message.
3
+ # Stolent from Mongrel.
4
+ HTTP_STATUS_CODES = {
5
+ 100 => 'Continue',
6
+ 101 => 'Switching Protocols',
7
+ 200 => 'OK',
8
+ 201 => 'Created',
9
+ 202 => 'Accepted',
10
+ 203 => 'Non-Authoritative Information',
11
+ 204 => 'No Content',
12
+ 205 => 'Reset Content',
13
+ 206 => 'Partial Content',
14
+ 300 => 'Multiple Choices',
15
+ 301 => 'Moved Permanently',
16
+ 302 => 'Moved Temporarily',
17
+ 303 => 'See Other',
18
+ 304 => 'Not Modified',
19
+ 305 => 'Use Proxy',
20
+ 400 => 'Bad Request',
21
+ 401 => 'Unauthorized',
22
+ 402 => 'Payment Required',
23
+ 403 => 'Forbidden',
24
+ 404 => 'Not Found',
25
+ 405 => 'Method Not Allowed',
26
+ 406 => 'Not Acceptable',
27
+ 407 => 'Proxy Authentication Required',
28
+ 408 => 'Request Time-out',
29
+ 409 => 'Conflict',
30
+ 410 => 'Gone',
31
+ 411 => 'Length Required',
32
+ 412 => 'Precondition Failed',
33
+ 413 => 'Request Entity Too Large',
34
+ 414 => 'Request-URI Too Large',
35
+ 415 => 'Unsupported Media Type',
36
+ 500 => 'Internal Server Error',
37
+ 501 => 'Not Implemented',
38
+ 502 => 'Bad Gateway',
39
+ 503 => 'Service Unavailable',
40
+ 504 => 'Gateway Time-out',
41
+ 505 => 'HTTP Version not supported'
42
+ }
43
+ end
@@ -0,0 +1,32 @@
1
+ module Thin
2
+ # Raised when a feature is not supported on the
3
+ # current platform.
4
+ class PlatformNotSupported < RuntimeError; end
5
+
6
+ module VERSION #:nodoc:
7
+ MAJOR = 1
8
+ MINOR = 4
9
+ TINY = 1
10
+
11
+ STRING = [MAJOR, MINOR, TINY].join('.')
12
+
13
+ CODENAME = "Chromeo".freeze
14
+
15
+ RACK = [1, 0].freeze # Rack protocol version
16
+ end
17
+
18
+ NAME = 'thin'.freeze
19
+ SERVER = "#{NAME} #{VERSION::STRING} codename #{VERSION::CODENAME}".freeze
20
+
21
+ def self.win?
22
+ RUBY_PLATFORM =~ /mswin|mingw/
23
+ end
24
+
25
+ def self.linux?
26
+ RUBY_PLATFORM =~ /linux/
27
+ end
28
+
29
+ def self.ruby_18?
30
+ RUBY_VERSION =~ /^1\.8/
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: friendlyfashion-thin
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.4.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Laurynas Butkus
9
+ - Tomas Didziokas
10
+ - Justas Janauskas
11
+ - Edvinas Bartkus
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2012-09-05 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: rack
19
+ requirement: !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: 1.0.0
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: eventmachine
35
+ requirement: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.12.6
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: 0.12.6
49
+ - !ruby/object:Gem::Dependency
50
+ name: daemons
51
+ requirement: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: 1.0.9
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: 1.0.9
65
+ description: A thin and fast web server
66
+ email:
67
+ - laurynas.butkus@gmail.com
68
+ - tomas.did@gmail.com
69
+ - jjanauskas@gmail.com
70
+ - edvinas.bartkus@gmail.com
71
+ executables:
72
+ - thin
73
+ extensions:
74
+ - ext/thin_parser/extconf.rb
75
+ extra_rdoc_files: []
76
+ files:
77
+ - CHANGELOG
78
+ - README.md
79
+ - Rakefile
80
+ - bin/thin
81
+ - example/myapp.rb
82
+ - example/monit_unixsock
83
+ - example/ramaze.ru
84
+ - example/vlad.rake
85
+ - example/monit_sockets
86
+ - example/thin_solaris_smf.erb
87
+ - example/thin_solaris_smf.readme.txt
88
+ - example/config.ru
89
+ - example/async_app.ru
90
+ - example/adapter.rb
91
+ - example/thin.god
92
+ - example/async_tailer.ru
93
+ - example/async_chat.ru
94
+ - lib/thin/stats.rb
95
+ - lib/thin/headers.rb
96
+ - lib/thin/controllers/service.rb
97
+ - lib/thin/controllers/controller.rb
98
+ - lib/thin/controllers/cluster.rb
99
+ - lib/thin/controllers/service.sh.erb
100
+ - lib/thin/backends/tcp_server.rb
101
+ - lib/thin/backends/swiftiply_client.rb
102
+ - lib/thin/backends/unix_server.rb
103
+ - lib/thin/backends/base.rb
104
+ - lib/thin/stats.html.erb
105
+ - lib/thin/runner.rb
106
+ - lib/thin/request.rb
107
+ - lib/thin/logging.rb
108
+ - lib/thin/command.rb
109
+ - lib/thin/version.rb
110
+ - lib/thin/server.rb
111
+ - lib/thin/response.rb
112
+ - lib/thin/daemonizing.rb
113
+ - lib/thin/connection.rb
114
+ - lib/thin/statuses.rb
115
+ - lib/rack/adapter/loader.rb
116
+ - lib/rack/adapter/rails.rb
117
+ - lib/thin.rb
118
+ - ext/thin_parser/parser.h
119
+ - ext/thin_parser/ext_help.h
120
+ - ext/thin_parser/thin.c
121
+ - ext/thin_parser/parser.c
122
+ - ext/thin_parser/extconf.rb
123
+ - ext/thin_parser/parser.rl
124
+ - ext/thin_parser/common.rl
125
+ homepage: http://code.macournoyer.com/thin/
126
+ licenses:
127
+ - Ruby
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: 1.8.5
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ requirements: []
145
+ rubyforge_project: thin
146
+ rubygems_version: 1.8.24
147
+ signing_key:
148
+ specification_version: 3
149
+ summary: A thin and fast web server
150
+ test_files: []
151
+ has_rdoc: