thin 0.6.3-x86-mswin32-60 → 0.6.4-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,4 +1,9 @@
1
+ == 0.6.4 Sexy Lobster release
2
+ * Fix error when stopping server on UNIX domain socket, fixes #42
3
+ * Rescue errors in Connection#get_peername more gracefully, setting REMOTE_ADDR to nil, fixes #43
4
+
1
5
  == 0.6.3 Ninja Cookie release
6
+ * Add tasks for Vlad the Deployer in example/vlad.rake [cnantais]
2
7
  * Add Ramaze Rackup config file in example dir [tmm1]
3
8
  Use like this from you Ramaze app dir:
4
9
 
@@ -17,10 +22,10 @@
17
22
 
18
23
  * thin config --chrdir ... -C thin/yml do not change current directory anymore, fixes #33.
19
24
  * Add a better sample god config file in example/thin.god that loads all info from config
20
- files in /etc/thin [Gump].
21
- * Add support for specifying a custom Connector to the server and a more doc about Server
25
+ files in /etc/thin. Drop-in replacement for the thin runlevel service [Gump].
26
+ * Add support for specifying a custom Connector to the server and add more doc about Server
22
27
  configuration.
23
- * Add a script to run thin as a system service that can start at startup, closes #31 [Gump]
28
+ * Add a script to run thin as a runlevel service that can start at startup, closes #31 [Gump]
24
29
  Setup the service like this:
25
30
 
26
31
  sudo thin install /etc/thin
data/example/vlad.rake ADDED
@@ -0,0 +1,61 @@
1
+ # $GEM_HOME/gems/vlad-1.2.0/lib/vlad/thin.rb
2
+ # Thin tasks for Vlad the Deployer
3
+ # By cnantais
4
+ require 'vlad'
5
+
6
+ namespace :vlad do
7
+ ##
8
+ # Thin app server
9
+
10
+ set :thin_address, "127.0.0.1"
11
+ set :thin_command, 'thin'
12
+ set(:thin_conf) { "#{shared_path}/thin_cluster.conf" }
13
+ set :thin_environment, "production"
14
+ set :thin_group, nil
15
+ set :thin_log_file, nil
16
+ set :thin_pid_file, nil
17
+ set :thin_port, nil
18
+ set :thin_socket, "/tmp/thin.sock"
19
+ set :thin_prefix, nil
20
+ set :thin_servers, 2
21
+ set :thin_user, nil
22
+
23
+ desc "Prepares application servers for deployment. thin
24
+ configuration is set via the thin_* variables.".cleanup
25
+
26
+ remote_task :setup_app, :roles => :app do
27
+ cmd = [
28
+ "#{thin_command} config",
29
+ "-s #{thin_servers}",
30
+ "-S #{thin_socket}",
31
+ "-e #{thin_environment}",
32
+ "-a #{thin_address}",
33
+ "-c #{current_path}",
34
+ "-C #{thin_conf}",
35
+ ("-P #{thin_pid_file}" if thin_pid_file),
36
+ ("-l #{thin_log_file}" if thin_log_file),
37
+ ("--user #{thin_user}" if thin_user),
38
+ ("--group #{thin_group}" if thin_group),
39
+ ("--prefix #{thin_prefix}" if thin_prefix),
40
+ ("-p #{thin_port}" if thin_port),
41
+ ].compact.join ' '
42
+
43
+ run cmd
44
+ end
45
+
46
+ def thin(cmd) # :nodoc:
47
+ "#{thin_command} #{cmd} -C #{thin_conf}"
48
+ end
49
+
50
+ desc "Restart the app servers"
51
+
52
+ remote_task :start_app, :roles => :app do
53
+ run thin("restart -s #{thin_servers}")
54
+ end
55
+
56
+ desc "Stop the app servers"
57
+
58
+ remote_task :stop_app, :roles => :app do
59
+ run thin("stop -s #{thin_servers}")
60
+ end
61
+ end
@@ -11,6 +11,8 @@ module Thin
11
11
  # Connector to the server
12
12
  attr_accessor :connector
13
13
 
14
+ attr_accessor :request, :response
15
+
14
16
  def post_init
15
17
  @request = Request.new
16
18
  @response = Response.new
@@ -53,9 +55,11 @@ module Thin
53
55
  @connector.connection_finished(self)
54
56
  end
55
57
 
56
- protected
57
- def remote_address
58
- @request.env[Request::FORWARDED_FOR] || Socket.unpack_sockaddr_in(get_peername)[1]
59
- end
58
+ def remote_address
59
+ @request.env[Request::FORWARDED_FOR] || Socket.unpack_sockaddr_in(get_peername)[1]
60
+ rescue
61
+ log_error($!)
62
+ nil
63
+ end
60
64
  end
61
65
  end
@@ -1,6 +1,6 @@
1
1
  module Thin
2
2
  module Connectors
3
- # Connectior to act as a UNIX domain socket server.
3
+ # Connector to act as a UNIX domain socket server.
4
4
  class UnixServer < Connector
5
5
  # UNIX domain socket on which the server is listening for connections.
6
6
  attr_accessor :socket
@@ -14,7 +14,10 @@ module Thin
14
14
  # Connect the server
15
15
  def connect
16
16
  at_exit { remove_socket_file } # In case it crashes
17
- @signature = EventMachine.start_unix_domain_server(@socket, UnixConnection, &method(:initialize_connection))
17
+ EventMachine.start_unix_domain_server(@socket, UnixConnection, &method(:initialize_connection))
18
+ # HACK EventMachine.start_unix_domain_server doesn't return the connection signature
19
+ # so we have to go in the internal stuff to find it.
20
+ @signature = EventMachine.instance_eval{@acceptors.keys.first}
18
21
  end
19
22
 
20
23
  # Stops the server
@@ -38,11 +41,14 @@ module Thin
38
41
  end
39
42
  end
40
43
 
44
+ # Connection through a UNIX domain socket.
41
45
  class UnixConnection < Connection
42
- protected
43
- def remote_address
44
- # FIXME not sure about this, does it even make sense on a UNIX socket?
45
- Socket.unpack_sockaddr_un(get_peername)
46
- end
46
+ def remote_address
47
+ # FIXME not sure about this, does it even make sense on a UNIX socket?
48
+ Socket.unpack_sockaddr_un(get_peername)
49
+ rescue
50
+ log_error($!)
51
+ nil
52
+ end
47
53
  end
48
54
  end
data/lib/thin/version.rb CHANGED
@@ -6,11 +6,11 @@ module Thin
6
6
  module VERSION #:nodoc:
7
7
  MAJOR = 0
8
8
  MINOR = 6
9
- TINY = 3
9
+ TINY = 4
10
10
 
11
11
  STRING = [MAJOR, MINOR, TINY].join('.')
12
12
 
13
- CODENAME = 'Ninja Cookie'
13
+ CODENAME = 'Sexy Lobster'
14
14
  end
15
15
 
16
16
  NAME = 'thin'.freeze
data/lib/thin_parser.so CHANGED
Binary file
@@ -0,0 +1,48 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe Connection do
4
+ before do
5
+ @connection = Connection.new(mock('EM', :null_object => true))
6
+ @connection.silent = true
7
+ @connection.post_init
8
+ @connection.app = proc do |env|
9
+ [200, {}, ['']]
10
+ end
11
+ end
12
+
13
+ it "should parse on receive_data" do
14
+ @connection.request.should_receive(:parse).with('GET')
15
+ @connection.receive_data('GET')
16
+ end
17
+
18
+ it "should close connection on InvalidRequest error in receive_data" do
19
+ @connection.request.stub!(:parse).and_raise(InvalidRequest)
20
+ @connection.should_receive(:close_connection)
21
+ @connection.receive_data('')
22
+ end
23
+
24
+ it "should process when parsing complete" do
25
+ @connection.request.should_receive(:parse).and_return(true)
26
+ @connection.should_receive(:process)
27
+ @connection.receive_data('GET')
28
+ end
29
+
30
+ it "should process" do
31
+ @connection.process
32
+ end
33
+
34
+ it "should return HTTP_X_FORWARDED_FOR as remote_address" do
35
+ @connection.request.env['HTTP_X_FORWARDED_FOR'] = '1.2.3.4'
36
+ @connection.remote_address.should == '1.2.3.4'
37
+ end
38
+
39
+ it "should return nil on error retreiving remote_address" do
40
+ @connection.stub!(:get_peername).and_raise(RuntimeError)
41
+ @connection.remote_address.should be_nil
42
+ end
43
+
44
+ it "should return remote_address" do
45
+ @connection.stub!(:get_peername).and_return("\020\002?E\177\000\000\001\000\000\000\000\000\000\000\000")
46
+ @connection.remote_address.should == '127.0.0.1'
47
+ end
48
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Connectors::TcpServer do
4
+ before do
5
+ @connector = Connectors::TcpServer.new('0.0.0.0', 3333)
6
+ end
7
+
8
+ it "should connect" do
9
+ EventMachine.run do
10
+ @connector.connect
11
+ EventMachine.stop
12
+ end
13
+ end
14
+
15
+ it "should disconnect" do
16
+ EventMachine.run do
17
+ @connector.connect
18
+ @connector.disconnect
19
+ EventMachine.stop
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Connectors::UnixServer do
4
+ before do
5
+ @connector = Connectors::UnixServer.new('/tmp/thin-test.sock')
6
+ end
7
+
8
+ it "should connect" do
9
+ EventMachine.run do
10
+ @connector.connect
11
+ EventMachine.stop
12
+ end
13
+ end
14
+
15
+ it "should disconnect" do
16
+ EventMachine.run do
17
+ @connector.connect
18
+ @connector.disconnect
19
+ EventMachine.stop
20
+ end
21
+ end
22
+
23
+ it "should remove socket file on close" do
24
+ @connector.close
25
+ File.exist?('/tmp/thin-test.sock').should be_false
26
+ end
27
+ end
28
+
29
+ describe UnixConnection do
30
+ before do
31
+ @connection = UnixConnection.new(nil)
32
+ end
33
+
34
+ it "should return nil on error retreiving remote_address" do
35
+ @connection.stub!(:get_peername).and_raise(RuntimeError)
36
+ @connection.remote_address.should be_nil
37
+ end
38
+
39
+ it "should return remote_address" do
40
+ @connection.stub!(:get_peername).and_return("\000\001127.0.0.1\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")
41
+ @connection.remote_address.should == '127.0.0.1'
42
+ end
43
+ end
data/tasks/gem.rake CHANGED
@@ -74,7 +74,14 @@ namespace :gem do
74
74
  sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}.gem"
75
75
  sh "rubyforge add_file thin thin #{Thin::VERSION::STRING} pkg/#{spec.full_name}-x86-mswin32-60.gem"
76
76
  end
77
- end
77
+ end
78
+
79
+ desc 'Download the Windows gem from Kevin repo'
80
+ task 'download:win' => 'pkg' do
81
+ cd 'pkg' do
82
+ `wget http://rubygems.bantamtech.com/ruby18/gems/#{spec.full_name}-x86-mswin32-60.gem`
83
+ end
84
+ end
78
85
  end
79
86
 
80
87
  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.3
4
+ version: 0.6.4
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-02-07 00:00:00 -07:00
12
+ date: 2008-02-13 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -54,6 +54,7 @@ files:
54
54
  - example/monit_unixsock
55
55
  - example/ramaze.ru
56
56
  - example/thin.god
57
+ - example/vlad.rake
57
58
  - lib/rack
58
59
  - lib/rack/adapter
59
60
  - lib/rack/adapter/rails.rb
@@ -88,6 +89,10 @@ files:
88
89
  - spec/configs
89
90
  - spec/configs/cluster.yml
90
91
  - spec/configs/single.yml
92
+ - spec/connection_spec.rb
93
+ - spec/connectors
94
+ - spec/connectors/tcp_server_spec.rb
95
+ - spec/connectors/unix_server_spec.rb
91
96
  - spec/controllers
92
97
  - spec/controllers/cluster_spec.rb
93
98
  - spec/controllers/controller_spec.rb