thin 0.8.1 → 0.8.2

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,10 @@
1
+ == 0.8.2 Double Margarita release
2
+ * Require EventMachine 0.12.0
3
+ * [bug] Fix timeout handling when running command
4
+ * [bug] Fix hanging when restarting and no process is running in single server move, fixes #67
5
+ * Added Mack adapter [markbates]
6
+ * Allow rackup .rb files by getting a conventionally named constant as the app [bmizerany]
7
+
1
8
  == 0.8.1 Rebel Porpoise release
2
9
  * [bug] Rescue all types of errors when processing request, fixes #62
3
10
  * [bug] Use Swiftiply backend when -y option is specified, fixes #63 and #64
data/example/myapp.rb ADDED
@@ -0,0 +1 @@
1
+ Myapp = lambda { |env| [200, {}, 'this is my app!'] }
@@ -9,6 +9,7 @@ module Rack
9
9
  :ramaze => "start.rb",
10
10
  :merb => "config/init.rb",
11
11
  :halcyon => 'runner.ru',
12
+ :mack => 'config/app_config/default.yml',
12
13
  :file => nil
13
14
  }
14
15
 
@@ -57,6 +58,11 @@ module Rack
57
58
 
58
59
  return Halcyon::Runner.new
59
60
 
61
+ when :mack
62
+ ENV["MACK_ENV"] = options[:environment]
63
+ load(::File.join(options[:chdir], "Rakefile"))
64
+ require 'mack'
65
+ return Mack::Utils::Server.build_app
60
66
  when :file
61
67
  return Rack::File.new(options[:chdir])
62
68
 
@@ -7,7 +7,6 @@ module Thin
7
7
 
8
8
  def initialize(socket)
9
9
  raise PlatformNotSupported, 'UNIX domain sockets not available on Windows' if Thin.win?
10
- check_event_machine_version
11
10
  @socket = socket
12
11
  super()
13
12
  end
@@ -39,17 +38,6 @@ module Thin
39
38
  def remove_socket_file
40
39
  File.delete(@socket) if @socket && File.exist?(@socket)
41
40
  end
42
-
43
- def check_event_machine_version
44
- # TODO remove this crap once eventmachine 0.11.0 is released
45
- begin
46
- gem 'eventmachine', '>= 0.11.0'
47
- rescue Gem::LoadError
48
- raise LoadError, "UNIX domain sockets require EventMachine version 0.11.0 or higher, " +
49
- "install the (not yet released) gem with: " +
50
- "gem install eventmachine --source http://code.macournoyer.com"
51
- end
52
- end
53
41
  end
54
42
  end
55
43
 
@@ -83,17 +83,19 @@ module Thin
83
83
  raise OptionRequired, :pid unless @options[:pid]
84
84
 
85
85
  tail_log(@options[:log]) do
86
- Server.kill(@options[:pid], @options[:timeout] || 60)
87
- wait_for_file :deletion, @options[:pid]
86
+ if Server.kill(@options[:pid], @options[:timeout] || 60)
87
+ wait_for_file :deletion, @options[:pid]
88
+ end
88
89
  end
89
90
  end
90
91
 
91
92
  def restart
92
93
  raise OptionRequired, :pid unless @options[:pid]
93
-
94
+
94
95
  tail_log(@options[:log]) do
95
- Server.restart(@options[:pid])
96
- wait_for_file :creation, @options[:pid]
96
+ if Server.restart(@options[:pid])
97
+ wait_for_file :creation, @options[:pid]
98
+ end
97
99
  end
98
100
  end
99
101
 
@@ -110,9 +112,11 @@ module Thin
110
112
  protected
111
113
  # Wait for a pid file to either be created or deleted.
112
114
  def wait_for_file(state, file)
113
- case state
114
- when :creation then sleep 0.1 until File.exist?(file)
115
- when :deletion then sleep 0.1 while File.exist?(file)
115
+ Timeout.timeout(@options[:timeout] || 30) do
116
+ case state
117
+ when :creation then sleep 0.1 until File.exist?(file)
118
+ when :deletion then sleep 0.1 while File.exist?(file)
119
+ end
116
120
  end
117
121
  end
118
122
 
@@ -161,8 +165,16 @@ module Thin
161
165
  end
162
166
 
163
167
  def load_rackup_config
164
- rackup_code = File.read(@options[:rackup])
165
- eval("Rack::Builder.new {( #{rackup_code}\n )}.to_app", TOPLEVEL_BINDING, @options[:rackup])
168
+ case @options[:rackup]
169
+ when /\.rb$/
170
+ Kernel.load(@options[:rackup])
171
+ Object.const_get(File.basename(@options[:rackup], '.rb').capitalize.to_sym)
172
+ when /\.ru$/
173
+ rackup_code = File.read(@options[:rackup])
174
+ eval("Rack::Builder.new {( #{rackup_code}\n )}.to_app", TOPLEVEL_BINDING, @options[:rackup])
175
+ else
176
+ raise "Invalid rackup file. please specify either a .ru or .rb file"
177
+ end
166
178
  end
167
179
  end
168
180
  end
@@ -94,17 +94,16 @@ module Thin
94
94
  # sent.
95
95
  def kill(pid_file, timeout=60)
96
96
  if pid = send_signal('QUIT', pid_file)
97
- begin
98
- Timeout.timeout(timeout) do
99
- sleep 0.1 while Process.running?(pid)
100
- end
101
- rescue Timeout::Error
102
- print "Timeout! "
103
- send_signal('KILL', pid_file)
104
- rescue Interrupt
105
- send_signal('KILL', pid_file)
97
+ Timeout.timeout(timeout) do
98
+ sleep 0.1 while Process.running?(pid)
106
99
  end
107
100
  end
101
+ rescue Timeout::Error
102
+ print "Timeout! "
103
+ send_signal('KILL', pid_file)
104
+ rescue Interrupt
105
+ send_signal('KILL', pid_file)
106
+ ensure
108
107
  File.delete(pid_file) if File.exist?(pid_file)
109
108
  end
110
109
 
data/lib/thin/runner.rb CHANGED
@@ -174,7 +174,7 @@ module Thin
174
174
 
175
175
  # +true+ if we're controlling a cluster.
176
176
  def cluster?
177
- @options[:only] || @options[:servers]
177
+ @options[:only] || @options[:servers] || @options[:config]
178
178
  end
179
179
 
180
180
  # +true+ if we're acting a as system service.
data/lib/thin/version.rb CHANGED
@@ -6,11 +6,11 @@ module Thin
6
6
  module VERSION #:nodoc:
7
7
  MAJOR = 0
8
8
  MINOR = 8
9
- TINY = 1
9
+ TINY = 2
10
10
 
11
11
  STRING = [MAJOR, MINOR, TINY].join('.')
12
12
 
13
- CODENAME = 'Rebel Porpoise'
13
+ CODENAME = 'Double Margarita'
14
14
 
15
15
  RACK = [0, 3].freeze # Latest Rack version that was tested
16
16
  end
Binary file
@@ -63,11 +63,25 @@ describe Controller, 'start' do
63
63
  end
64
64
 
65
65
  it "should load app from Rack config" do
66
- @controller.options[:rackup] = 'example/config.ru'
66
+ @controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/config.ru'
67
67
  @controller.start
68
68
 
69
69
  @server.app.class.should == Proc
70
70
  end
71
+
72
+ it "should load app from ruby file" do
73
+ @controller.options[:rackup] = filename = File.dirname(__FILE__) + '/../../example/myapp.rb'
74
+ @controller.start
75
+
76
+ @server.app.should == Myapp
77
+ end
78
+
79
+ it "should throwup if rackup is not a .ru or .rb file" do
80
+ proc do
81
+ @controller.options[:rackup] = filename = File.dirname(__FILE__) + '/../../example/myapp.foo'
82
+ @controller.start
83
+ end.should raise_error(RuntimeError, /please/)
84
+ end
71
85
 
72
86
  it "should set server as threaded" do
73
87
  @controller.options[:threaded] = true
@@ -75,6 +89,7 @@ describe Controller, 'start' do
75
89
 
76
90
  @server.threaded.should be_true
77
91
  end
92
+
78
93
  end
79
94
 
80
95
  describe Controller do
@@ -133,6 +133,12 @@ describe 'Daemonizing' do
133
133
  proc { sleep 0.1 while File.exist?(@server.pid_file) }.should take_less_then(10)
134
134
  end
135
135
 
136
+ it "should not restart when not running" do
137
+ silence_stream STDOUT do
138
+ TestServer.restart(@server.pid_file)
139
+ end
140
+ end
141
+
136
142
  it "should exit and raise if pid file already exist" do
137
143
  @pid = fork do
138
144
  @server.daemonize
@@ -173,6 +173,18 @@ EOS
173
173
  end
174
174
  end
175
175
 
176
+ xit "should parse absolute request URI" do
177
+ request = R(<<-EOS, true)
178
+ GET http://localhost:3000/hi HTTP/1.1
179
+ Host: localhost:3000
180
+
181
+ EOS
182
+ request.env['PATH_INFO'].should == '/hi'
183
+
184
+ request.should validate_with_lint
185
+ end
186
+
187
+
176
188
  it "should fails on heders larger then MAX_HEADER" do
177
189
  proc { R("GET / HTTP/1.1\r\nFoo: #{'X' * Request::MAX_HEADER}\r\n\r\n") }.should raise_error(InvalidRequest)
178
190
  end
data/tasks/gem.rake CHANGED
@@ -19,12 +19,10 @@ spec = Gem::Specification.new do |s|
19
19
 
20
20
  s.required_ruby_version = '>= 1.8.5'
21
21
 
22
- s.add_dependency 'rack', '>= 0.2.0'
23
- if WIN
24
- s.add_dependency 'eventmachine', '= 0.8.1' # TODO replace w/ latest precompiled
25
- else
22
+ s.add_dependency 'rack', '>= 0.3.0'
23
+ s.add_dependency 'eventmachine', '>= 0.12.0'
24
+ unless WIN
26
25
  s.add_dependency 'daemons', '>= 1.0.9'
27
- s.add_dependency 'eventmachine', '>= 0.10.0' # TODO '>= 0.11.0' when it's released
28
26
  end
29
27
 
30
28
  s.files = %w(COPYING CHANGELOG COMMITTERS README Rakefile) +
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.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
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-04-19 00:00:00 -04:00
12
+ date: 2008-06-24 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -19,25 +19,25 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.2.0
22
+ version: 0.3.0
23
23
  version:
24
24
  - !ruby/object:Gem::Dependency
25
- name: daemons
25
+ name: eventmachine
26
26
  version_requirement:
27
27
  version_requirements: !ruby/object:Gem::Requirement
28
28
  requirements:
29
29
  - - ">="
30
30
  - !ruby/object:Gem::Version
31
- version: 1.0.9
31
+ version: 0.12.0
32
32
  version:
33
33
  - !ruby/object:Gem::Dependency
34
- name: eventmachine
34
+ name: daemons
35
35
  version_requirement:
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.10.0
40
+ version: 1.0.9
41
41
  version:
42
42
  description: A thin and fast web server
43
43
  email: macournoyer@gmail.com
@@ -61,6 +61,7 @@ files:
61
61
  - example/config.ru
62
62
  - example/monit_sockets
63
63
  - example/monit_unixsock
64
+ - example/myapp.rb
64
65
  - example/ramaze.ru
65
66
  - example/thin.god
66
67
  - example/thin_solaris_smf.erb