thin 0.6.0-x86-mswin32-60 → 0.6.1-x86-mswin32-60

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.

data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.6.1 Cheesecake release
2
+ * Remove socket file when server stops.
3
+ * Set back cluster to use 'thin' command to launch servers.
4
+
1
5
  == 0.6.0 Big Pony release
2
6
  * Add support for connection through UNIX domain socket.
3
7
  Use the --socket (-S) option w/ the thin script to configure the socket filename.
data/benchmark/simple.rb CHANGED
@@ -9,5 +9,6 @@ require File.dirname(__FILE__) + '/../lib/thin'
9
9
  require File.dirname(__FILE__) + '/utils'
10
10
 
11
11
  request = (ARGV[0] || 1000).to_i # Number of request to send (ab -n option)
12
+ output_type = (ARGV[1] || 'print')
12
13
 
13
- benchmark %w(WEBrick Mongrel EMongrel Thin), request
14
+ benchmark output_type, %w(WEBrick Mongrel EMongrel Thin), request, [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
data/benchmark/utils.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'rack/lobster'
2
2
 
3
3
  def run(handler_name, n=1000, c=1)
4
+ port = 7000
5
+
4
6
  server = fork do
5
7
  [STDOUT, STDERR].each { |o| o.reopen "/dev/null" }
6
8
 
@@ -22,27 +24,49 @@ def run(handler_name, n=1000, c=1)
22
24
  app = Rack::Lobster.new
23
25
 
24
26
  handler = Rack::Handler.const_get(handler_name)
25
- handler.run app, :Host => '0.0.0.0', :Port => 7000
27
+ handler.run app, :Host => '0.0.0.0', :Port => port
26
28
  end
27
29
 
28
30
  sleep 2
29
31
 
30
- out = `nice -n20 ab -c #{c} -n #{n} http://127.0.0.1:7000/ 2> /dev/null`
32
+ out = `nice -n20 ab -c #{c} -n #{n} http://127.0.0.1:port/ 2> /dev/null`
31
33
 
32
34
  Process.kill('SIGKILL', server)
33
35
  Process.wait
34
36
 
35
37
  if requests = out.match(/^Requests.+?(\d+\.\d+)/)
36
- failed = out.match(/^Failed requests.+?(\d+)$/)[1]
37
- "#{requests[1].to_s.ljust(9)} #{failed}"
38
+ requests[1].to_i
38
39
  else
39
- 'ERROR'
40
+ 0
40
41
  end
41
42
  end
42
43
 
43
- def benchmark(servers, request, concurrency_levels=[1, 10, 100])
44
- puts 'server request concurrency req/s failures'
45
- puts '=' * 53
44
+ def benchmark(type, servers, request, concurrency_levels)
45
+ send "#{type}_benchmark", servers, request, concurrency_levels
46
+ end
47
+
48
+ def graph_benchmark(servers, request, concurrency_levels)
49
+ require '/usr/local/lib/ruby/gems/1.8/gems/gruff-0.2.9/lib/gruff'
50
+ g = Gruff::Area.new
51
+ g.title = "Server benchmark"
52
+
53
+ servers.each do |server|
54
+ g.data(server, concurrency_levels.collect { |c| print '.'; run(server, request, c) })
55
+ end
56
+ puts
57
+
58
+ g.x_axis_label = 'Concurrency'
59
+ g.y_axis_label = 'Requests / sec'
60
+ g.labels = {}
61
+ concurrency_levels.each_with_index { |c, i| g.labels[i] = c.to_s }
62
+
63
+ g.write('bench.png')
64
+ `open bench.png`
65
+ end
66
+
67
+ def print_benchmark(servers, request, concurrency_levels)
68
+ puts 'server request concurrency req/s'
69
+ puts '=' * 42
46
70
  concurrency_levels.each do |c|
47
71
  servers.each do |server|
48
72
  puts "#{server.ljust(8)} #{request} #{c.to_s.ljust(4)} #{run(server, request, c)}"
data/lib/thin/cluster.rb CHANGED
@@ -20,7 +20,7 @@ module Thin
20
20
  def initialize(options)
21
21
  @options = options.merge(:daemonize => true)
22
22
  @size = @options.delete(:servers)
23
- @script = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'thin')
23
+ @script = 'thin'
24
24
 
25
25
  if socket
26
26
  @options.delete(:address)
data/lib/thin/server.rb CHANGED
@@ -43,12 +43,12 @@ module Thin
43
43
  def initialize(host_or_socket, port=3000, app=nil, &block)
44
44
  if host_or_socket.include?('/')
45
45
  @socket = host_or_socket
46
- else
47
- @host = host_or_socket
48
- @port = port.to_i
49
- end
50
- @app = app
51
- @timeout = 60 # sec
46
+ else
47
+ @host = host_or_socket
48
+ @port = port.to_i
49
+ end
50
+ @app = app
51
+ @timeout = 60 # sec
52
52
 
53
53
  @app = Rack::Builder.new(&block).to_app if block
54
54
  end
@@ -59,10 +59,12 @@ module Thin
59
59
 
60
60
  # Start the server and listen for connections
61
61
  def start
62
- raise ArgumentError, "app required" unless @app
62
+ raise ArgumentError, 'app required' unless @app
63
63
 
64
64
  trap('INT') { stop }
65
65
  trap('TERM') { stop! }
66
+
67
+ at_exit { remove_socket_file } if @socket
66
68
 
67
69
  # See http://rubyeventmachine.com/pub/rdoc/files/EPOLL.html
68
70
  EventMachine.epoll
@@ -83,6 +85,7 @@ module Thin
83
85
  # Stops the server by stopping the listening loop.
84
86
  def stop
85
87
  EventMachine.stop_event_loop
88
+ remove_socket_file
86
89
  rescue
87
90
  warn "Error stopping : #{$!}"
88
91
  end
@@ -117,5 +120,9 @@ module Thin
117
120
  connection.silent = @silent
118
121
  connection.unix_socket = !@socket.nil?
119
122
  end
123
+
124
+ def remove_socket_file
125
+ File.delete(@socket) if @socket && File.exist?(@socket)
126
+ end
120
127
  end
121
128
  end
data/lib/thin/version.rb CHANGED
@@ -2,10 +2,10 @@ module Thin
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 6
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
 
9
- CODENAME = 'Big Pony'
9
+ CODENAME = 'Cheesecake'
10
10
  end
11
11
  end
data/lib/thin_parser.so CHANGED
Binary file
data/spec/server_spec.rb CHANGED
@@ -122,11 +122,11 @@ describe Server, "on UNIX domain socket" do
122
122
  app = proc do |env|
123
123
  [200, { 'Content-Type' => 'text/html' }, [env.inspect]]
124
124
  end
125
- server = Thin::Server.new('/tmp/thin_test.sock', nil, app)
126
- server.timeout = 3
127
- server.silent = true
125
+ @server = Thin::Server.new('/tmp/thin_test.sock', nil, app)
126
+ @server.timeout = 3
127
+ @server.silent = true
128
128
 
129
- @thread = Thread.new { server.start }
129
+ @thread = Thread.new { @server.start }
130
130
  sleep 0.1 until @thread.status == 'sleep'
131
131
  end
132
132
 
@@ -140,7 +140,12 @@ describe Server, "on UNIX domain socket" do
140
140
 
141
141
  it "should handle GET in less then #{get_request_time = 0.002} RubySecond" do
142
142
  proc { get('/') }.should be_faster_then(get_request_time)
143
- end
143
+ end
144
+
145
+ it "should remove socket file after server stops" do
146
+ @server.stop
147
+ File.exist?('/tmp/thin_test.sock').should be_false
148
+ end
144
149
 
145
150
  after do
146
151
  @thread.kill
data/tasks/gem.rake CHANGED
@@ -42,9 +42,15 @@ end
42
42
  task :tag_warn do
43
43
  puts "*" * 40
44
44
  puts "Don't forget to tag the release:"
45
- puts " git tag -a v#{Thin::VERSION::STRING}"
45
+ puts
46
+ puts " git tag -m 'Tagging #{Thin::SERVER}' -a v#{Thin::VERSION::STRING}"
47
+ puts
48
+ puts "or run rake tag"
46
49
  puts "*" * 40
47
50
  end
51
+ task :tag do
52
+ sh "git tag -m 'Tagging #{Thin::SERVER}' -a v#{Thin::VERSION::STRING}"
53
+ end
48
54
  task :gem => :tag_warn
49
55
 
50
56
  namespace :gem do
@@ -54,12 +60,27 @@ namespace :gem do
54
60
  system 'ssh macournoyer@macournoyer.com "cd code.macournoyer.com && gem generate_index"'
55
61
  end
56
62
 
57
- desc 'Upload gem to rubyforge.org'
58
- task :upload_rubyforge => :gem do
59
- sh 'rubyforge login'
60
- sh "rubyforge add_release thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}.gem"
61
- sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}.gem"
62
- end
63
+ namespace :upload do
64
+ desc 'Upload the precompiled win32 gem to code.macournoyer.com'
65
+ task :win do
66
+ upload "pkg/#{spec.full_name}-x86-mswin32-60.gem", 'gems'
67
+ system 'ssh macournoyer@macournoyer.com "cd code.macournoyer.com && gem generate_index"'
68
+ end
69
+
70
+ desc 'Upload gem to rubyforge.org'
71
+ task :rubyforge => :gem do
72
+ sh 'rubyforge login'
73
+ sh "rubyforge add_release thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}.gem"
74
+ sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}.gem"
75
+ end
76
+
77
+ desc 'Upload the precompiled win32 gem to rubyforge.org'
78
+ task 'rubyforge:win' do
79
+ sh 'rubyforge login'
80
+ sh "rubyforge add_release thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}-x86-mswin32-60.gem"
81
+ sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}-x86-mswin32-60.gem"
82
+ end
83
+ end
63
84
  end
64
85
 
65
86
  task :install => [:clobber, :compile, :package] do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: x86-mswin32-60
6
6
  authors:
7
7
  - Marc-Andre Cournoyer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-01-25 00:00:00 -07:00
12
+ date: 2008-01-26 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency