thin 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ == 1.5.1 Straight Razor
2
+ * Fix issue when running as another user/group without a PID file.
3
+ * Allow overriding Connection & Server response headers.
4
+ * Update vlad example [Mathieu Lemoine]
5
+ * Keep connections in a Hash to speedup deletion [slivu]
6
+ * Force kill using already known pid. Prevents "thin stop" from leaving a process that removed its
7
+ pid file, but is still running (e.g. hung on some at_exit callback) [Michal Kwiatkowski]
8
+
1
9
  == 1.5.0 Knife
2
10
  * Fix compilation under Ubuntu 12.04 with -Werror=format-security option.
3
11
  * Raise an error when no PID file.
@@ -7,8 +7,8 @@ namespace :vlad do
7
7
  ##
8
8
  # Thin app server
9
9
 
10
- set :thin_address, "127.0.0.1"
11
- set :thin_command, 'thin'
10
+ set :thin_address, nil
11
+ set :thin_command, "thin"
12
12
  set(:thin_conf) { "#{shared_path}/thin_cluster.conf" }
13
13
  set :thin_environment, "production"
14
14
  set :thin_group, nil
@@ -19,6 +19,8 @@ namespace :vlad do
19
19
  set :thin_prefix, nil
20
20
  set :thin_servers, 2
21
21
  set :thin_user, nil
22
+
23
+ set :thin_uses_bundler, true
22
24
 
23
25
  desc "Prepares application servers for deployment. thin
24
26
  configuration is set via the thin_* variables.".cleanup
@@ -28,37 +30,43 @@ configuration is set via the thin_* variables.".cleanup
28
30
  raise(ArgumentError, "Please provide either thin_socket or thin_port") if thin_port.nil? && thin_socket.nil?
29
31
 
30
32
  cmd = [
31
- "#{thin_command} config",
32
- "-s #{thin_servers}",
33
- ("-S #{thin_socket}" if thin_socket),
34
- "-e #{thin_environment}",
35
- "-a #{thin_address}",
36
- "-c #{current_path}",
37
- "-C #{thin_conf}",
38
- ("-P #{thin_pid_file}" if thin_pid_file),
39
- ("-l #{thin_log_file}" if thin_log_file),
40
- ("--user #{thin_user}" if thin_user),
41
- ("--group #{thin_group}" if thin_group),
42
- ("--prefix #{thin_prefix}" if thin_prefix),
43
- ("-p #{thin_port}" if thin_port),
33
+ "config",
34
+ (%(-s "#{thin_servers}") if thin_servers),
35
+ (%(-S "#{thin_socket}") if thin_socket),
36
+ (%(-e "#{thin_environment}") if thin_environment),
37
+ (%(-a "#{thin_address}") if thin_address),
38
+ %(-c "#{current_path}"),
39
+ (%(-C "#{thin_conf}") if thin_conf),
40
+ (%(-P "#{thin_pid_file}") if thin_pid_file),
41
+ (%(-l "#{thin_log_file}") if thin_log_file),
42
+ (%(--user "#{thin_user}") if thin_user),
43
+ (%(--group "#{thin_group}") if thin_group),
44
+ (%(--prefix "#{thin_prefix}") if thin_prefix),
45
+ (%(-p "#{thin_port}") if thin_port),
44
46
  ].compact.join ' '
45
47
 
46
- run cmd
48
+ thin(cmd)
47
49
  end
48
50
 
49
51
  def thin(cmd) # :nodoc:
50
- "#{thin_command} #{cmd} -C #{thin_conf}"
52
+ command = if thin_uses_bundler
53
+ %(BUNDLE_GEMFILE="#{current_path}/Gemfile" bundle exec #{thin_command} #{cmd} -C "#{thin_conf}")
54
+ else
55
+ %(#{thin_command} #{cmd} -C "#{thin_conf}")
56
+ end
57
+
58
+ %(cd "#{current_path}" && #{command})
51
59
  end
52
60
 
53
61
  desc "Restart the app servers"
54
62
 
55
63
  remote_task :start_app, :roles => :app do
56
- run thin("restart -O -s #{thin_servers}")
64
+ run thin(%(restart -O -s "#{thin_servers}"))
57
65
  end
58
66
 
59
67
  desc "Stop the app servers"
60
68
 
61
69
  remote_task :stop_app, :roles => :app do
62
- run thin("stop -s #{thin_servers}")
70
+ run thin(%(stop -s "#{thin_servers}"))
63
71
  end
64
72
  end
@@ -38,7 +38,7 @@ module Thin
38
38
  attr_accessor :no_epoll
39
39
 
40
40
  def initialize
41
- @connections = []
41
+ @connections = {}
42
42
  @timeout = Server::DEFAULT_TIMEOUT
43
43
  @persistent_connection_count = 0
44
44
  @maximum_connections = Server::DEFAULT_MAXIMUM_CONNECTIONS
@@ -72,7 +72,7 @@ module Thin
72
72
  # Do not accept anymore connection
73
73
  disconnect
74
74
  # Close idle persistent connections
75
- @connections.each { |connection| connection.close_connection if connection.idle? }
75
+ @connections.each_value { |connection| connection.close_connection if connection.idle? }
76
76
  stop! if @connections.empty?
77
77
  end
78
78
 
@@ -82,7 +82,7 @@ module Thin
82
82
  @stopping = false
83
83
 
84
84
  EventMachine.stop if EventMachine.reactor_running?
85
- @connections.each { |connection| connection.close_connection }
85
+ @connections.each_value { |connection| connection.close_connection }
86
86
  close
87
87
  end
88
88
 
@@ -110,7 +110,7 @@ module Thin
110
110
  # Called by a connection when it's unbinded.
111
111
  def connection_finished(connection)
112
112
  @persistent_connection_count -= 1 if connection.can_persist?
113
- @connections.delete(connection)
113
+ @connections.delete(connection.__id__)
114
114
 
115
115
  # Finalize gracefull stop if there's no more active connection.
116
116
  stop! if @stopping && @connections.empty?
@@ -145,7 +145,7 @@ module Thin
145
145
  @persistent_connection_count += 1
146
146
  end
147
147
 
148
- @connections << connection
148
+ @connections[connection.__id__] = connection
149
149
  end
150
150
 
151
151
  end
@@ -74,7 +74,7 @@ module Thin
74
74
 
75
75
  if uid != target_uid || gid != target_gid
76
76
  # Change PID file ownership
77
- File.chown(target_uid, target_gid, @pid_file)
77
+ File.chown(target_uid, target_gid, @pid_file) if File.exists?(@pid_file)
78
78
 
79
79
  # Change process ownership
80
80
  Process.initgroups(user, target_gid)
@@ -132,22 +132,18 @@ module Thin
132
132
  end
133
133
  rescue Timeout::Error
134
134
  Logging.log "Timeout!"
135
- force_kill pid_file
135
+ force_kill(pid, pid_file)
136
136
  rescue Interrupt
137
- force_kill pid_file
137
+ force_kill(pid, pid_file)
138
138
  rescue Errno::ESRCH # No such process
139
139
  Logging.log "process not found!"
140
- force_kill pid_file
140
+ force_kill(pid, pid_file)
141
141
  end
142
142
 
143
- def force_kill(pid_file)
144
- if pid = read_pid_file(pid_file)
145
- Logging.log "Sending KILL signal to process #{pid} ... "
146
- Process.kill("KILL", pid)
147
- File.delete(pid_file) if File.exist?(pid_file)
148
- else
149
- Logging.log "Can't stop process, no PID found in #{pid_file}"
150
- end
143
+ def force_kill(pid, pid_file)
144
+ Logging.log "Sending KILL signal to process #{pid} ... "
145
+ Process.kill("KILL", pid)
146
+ File.delete(pid_file) if File.exist?(pid_file)
151
147
  end
152
148
 
153
149
  def read_pid_file(file)
@@ -33,8 +33,8 @@ module Thin
33
33
  # to be sent in the response.
34
34
  def headers_output
35
35
  # Set default headers
36
- @headers[CONNECTION] = persistent? ? KEEP_ALIVE : CLOSE
37
- @headers[SERVER] = Thin::SERVER
36
+ @headers[CONNECTION] = persistent? ? KEEP_ALIVE : CLOSE unless @headers.has_key?(CONNECTION)
37
+ @headers[SERVER] = Thin::SERVER unless @headers.has_key?(SERVER)
38
38
 
39
39
  @headers.to_s
40
40
  end
@@ -6,11 +6,11 @@ module Thin
6
6
  module VERSION #:nodoc:
7
7
  MAJOR = 1
8
8
  MINOR = 5
9
- TINY = 0
9
+ TINY = 1
10
10
 
11
11
  STRING = [MAJOR, MINOR, TINY].join('.')
12
12
 
13
- CODENAME = "Knife".freeze
13
+ CODENAME = "Straight Razor".freeze
14
14
 
15
15
  RACK = [1, 0].freeze # Rack protocol version
16
16
  end
metadata CHANGED
@@ -1,60 +1,72 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: thin
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.5.1
4
5
  prerelease:
5
- version: 1.5.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Marc-Andre Cournoyer
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-09-22 00:00:00 -04:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2013-03-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: rack
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
24
21
  version: 1.0.0
25
22
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: eventmachine
29
23
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: eventmachine
32
+ requirement: !ruby/object:Gem::Requirement
31
33
  none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
35
37
  version: 0.12.6
36
38
  type: :runtime
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: daemons
40
39
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
42
41
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.12.6
46
+ - !ruby/object:Gem::Dependency
47
+ name: daemons
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
46
53
  version: 1.0.9
47
54
  type: :runtime
48
- version_requirements: *id003
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.9
49
62
  description: A thin and fast web server
50
63
  email: macournoyer@gmail.com
51
- executables:
64
+ executables:
52
65
  - thin
53
- extensions:
66
+ extensions:
54
67
  - ext/thin_parser/extconf.rb
55
68
  extra_rdoc_files: []
56
-
57
- files:
69
+ files:
58
70
  - CHANGELOG
59
71
  - README.md
60
72
  - Rakefile
@@ -103,33 +115,30 @@ files:
103
115
  - ext/thin_parser/extconf.rb
104
116
  - ext/thin_parser/common.rl
105
117
  - ext/thin_parser/parser.rl
106
- has_rdoc: true
107
118
  homepage: http://code.macournoyer.com/thin/
108
- licenses:
119
+ licenses:
109
120
  - Ruby
110
121
  post_install_message:
111
122
  rdoc_options: []
112
-
113
- require_paths:
123
+ require_paths:
114
124
  - lib
115
- required_ruby_version: !ruby/object:Gem::Requirement
125
+ required_ruby_version: !ruby/object:Gem::Requirement
116
126
  none: false
117
- requirements:
118
- - - ">="
119
- - !ruby/object:Gem::Version
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
120
130
  version: 1.8.5
121
- required_rubygems_version: !ruby/object:Gem::Requirement
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
132
  none: false
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- version: "0"
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
127
137
  requirements: []
128
-
129
138
  rubyforge_project: thin
130
- rubygems_version: 1.6.2
139
+ rubygems_version: 1.8.24
131
140
  signing_key:
132
141
  specification_version: 3
133
142
  summary: A thin and fast web server
134
143
  test_files: []
135
-
144
+ has_rdoc: