unicorn 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  GVF=GIT-VERSION-FILE
4
- DEF_VER=v1.1.3.GIT
4
+ DEF_VER=v1.1.4.GIT
5
5
 
6
6
  LF='
7
7
  '
data/HACKING CHANGED
@@ -16,8 +16,8 @@ Tests are good, but slow tests make development slow, so we make tests
16
16
  faster (in parallel) with GNU make (instead of Rake) and avoiding
17
17
  RubyGems.
18
18
 
19
- Users of GNU-based systems (such as GNU/Linux) usually have GNU make installed
20
- as "make" instead of "gmake".
19
+ Users of GNU-based systems (such as GNU/Linux) usually have GNU make
20
+ installed as "make" instead of "gmake".
21
21
 
22
22
  Since we don't load RubyGems by default, loading Rack properly requires
23
23
  setting up RUBYLIB to point to where Rack is located. Not loading
@@ -57,11 +57,18 @@ programming experience will come in handy (or be learned) here.
57
57
 
58
58
  === Documentation
59
59
 
60
- We use RDoc 2.4.x with Darkfish for documentation as much as possible,
60
+ We use RDoc 2.5.x with Darkfish for documentation as much as possible,
61
61
  if you're on Ruby 1.8 you want to install the latest "rdoc" gem. Due to
62
62
  the lack of RDoc-to-manpage converters we know about, we're writing
63
63
  manpages in Markdown and converting to troff/HTML with Pandoc.
64
64
 
65
+ Please wrap documentation at 72 characters-per-line or less (long URLs
66
+ are exempt) so it is comfortably readable from terminals.
67
+
68
+ When referencing mailing list posts, use
69
+ "http://mid.gmane.org/$MESSAGE_ID" if possible since the Message-ID
70
+ remains searchable even if Gmane becomes unavailable.
71
+
65
72
  === Ruby/C Compatibility
66
73
 
67
74
  We target Ruby 1.8.6+, 1.9 and will target Rubinius as it becomes
data/Rakefile CHANGED
@@ -207,7 +207,7 @@ task :isolate do
207
207
  status.success? or abort status.inspect
208
208
 
209
209
  # pure Ruby gems can be shared across all Rubies
210
- %w(3.0.0.rc2).each do |rails_ver|
210
+ %w(3.0.0).each do |rails_ver|
211
211
  opts[:path] = "tmp/isolate/rails-#{rails_ver}"
212
212
  pid = fork { Isolate.now!(opts) { gem 'rails', rails_ver } }
213
213
  _, status = Process.waitpid2(pid)
data/Sandbox CHANGED
@@ -24,6 +24,9 @@ this:
24
24
  Then use HUP to reload, and then continue with the USR2+QUIT upgrade
25
25
  sequence.
26
26
 
27
+ Environment variable pollution when exec-ing a new process (with USR2)
28
+ is the primary issue with sandboxing tools such as Bundler and Isolate.
29
+
27
30
  == Bundler
28
31
 
29
32
  === Running
@@ -42,6 +45,12 @@ This is no longer be an issue as of bundler 0.9.17
42
45
 
43
46
  ref: http://mid.gmane.org/8FC34B23-5994-41CC-B5AF-7198EF06909E@tramchase.com
44
47
 
48
+ === Other ENV pollution issues
49
+
50
+ You may need to set or reset BUNDLE_GEMFILE, GEM_HOME, GEM_PATH and PATH
51
+ environment variables in the before_exec hook as illustrated by
52
+ http://gist.github.com/534668
53
+
45
54
  == Isolate
46
55
 
47
56
  === Running
data/TUNING CHANGED
@@ -22,7 +22,13 @@ See Unicorn::Configurator for details on the config file format.
22
22
  listeners under Linux 2.6 because auto-tuning is enabled. UNIX domain
23
23
  sockets do not have auto-tuning buffer sizes; so increasing those will
24
24
  allow syscalls and task switches to be saved for larger requests
25
- and responses.
25
+ and responses. If your app only generates small responses or expects
26
+ small requests, you may shrink the buffer sizes to save memory, too.
27
+
28
+ * Having socket buffers too large can also be detrimental or have
29
+ little effect. Huge buffers can put more pressure on the allocator
30
+ and may also thrash CPU caches, cancelling out performance gains
31
+ one would normally expect.
26
32
 
27
33
  * Setting "preload_app true" can allow copy-on-write-friendly GC to
28
34
  be used to save memory. It will probably not work out of the box with
@@ -8,8 +8,8 @@ module Unicorn
8
8
  # Symbols did not really improve things much compared to constants.
9
9
  module Const
10
10
 
11
- # The current version of Unicorn, currently 1.1.3
12
- UNICORN_VERSION="1.1.3"
11
+ # The current version of Unicorn, currently 1.1.4
12
+ UNICORN_VERSION="1.1.4"
13
13
 
14
14
  DEFAULT_HOST = "0.0.0.0" # default TCP listen host address
15
15
  DEFAULT_PORT = 8080 # default TCP listen port
@@ -111,8 +111,14 @@ module Unicorn
111
111
  sock = if address[0] == ?/
112
112
  if File.exist?(address)
113
113
  if File.socket?(address)
114
- logger.info "unlinking existing socket=#{address}"
115
- File.unlink(address)
114
+ begin
115
+ UNIXSocket.new(address).close
116
+ # fall through, try to bind(2) and fail with EADDRINUSE
117
+ # (or succeed from a small race condition we can't sanely avoid).
118
+ rescue Errno::ECONNREFUSED
119
+ logger.info "unlinking existing socket=#{address}"
120
+ File.unlink(address)
121
+ end
116
122
  else
117
123
  raise ArgumentError,
118
124
  "socket=#{address} specified but it is not a socket!"
@@ -1,6 +1,6 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- # gem 'rails', '3.0.0.rc2'
3
+ # gem 'rails', '3.0.0'
4
4
 
5
5
  # Bundle edge Rails instead:
6
6
  # gem 'rails', :git => 'git://github.com/rails/rails.git'
@@ -0,0 +1,79 @@
1
+ #!/bin/sh
2
+ . ./test-lib.sh
3
+ t_plan 11 "existing UNIX domain socket check"
4
+
5
+ read_pid_unix () {
6
+ x=$(printf 'GET / HTTP/1.0\r\n\r\n' | \
7
+ socat - UNIX:$unix_socket | \
8
+ tail -1)
9
+ test -n "$x"
10
+ y="$(expr "$x" : '\([0-9]\+\)')"
11
+ test x"$x" = x"$y"
12
+ test -n "$y"
13
+ echo "$y"
14
+ }
15
+
16
+ t_begin "setup and start" && {
17
+ rtmpfiles unix_socket unix_config
18
+ rm -f $unix_socket
19
+ unicorn_setup
20
+ grep -v ^listen < $unicorn_config > $unix_config
21
+ echo "listen '$unix_socket'" >> $unix_config
22
+ unicorn -D -c $unix_config pid.ru
23
+ unicorn_wait_start
24
+ orig_master_pid=$unicorn_pid
25
+ }
26
+
27
+ t_begin "get pid of worker" && {
28
+ worker_pid=$(read_pid_unix)
29
+ t_info "worker_pid=$worker_pid"
30
+ }
31
+
32
+ t_begin "fails to start with existing pid file" && {
33
+ rm -f $ok
34
+ unicorn -D -c $unix_config pid.ru || echo ok > $ok
35
+ test x"$(cat $ok)" = xok
36
+ }
37
+
38
+ t_begin "worker pid unchanged" && {
39
+ test x"$(read_pid_unix)" = x$worker_pid
40
+ > $r_err
41
+ }
42
+
43
+ t_begin "fails to start with listening UNIX domain socket bound" && {
44
+ rm $ok $pid
45
+ unicorn -D -c $unix_config pid.ru || echo ok > $ok
46
+ test x"$(cat $ok)" = xok
47
+ > $r_err
48
+ }
49
+
50
+ t_begin "worker pid unchanged (again)" && {
51
+ test x"$(read_pid_unix)" = x$worker_pid
52
+ }
53
+
54
+ t_begin "nuking the existing Unicorn succeeds" && {
55
+ kill -9 $unicorn_pid $worker_pid
56
+ while kill -0 $unicorn_pid
57
+ do
58
+ sleep 1
59
+ done
60
+ check_stderr
61
+ }
62
+
63
+ t_begin "succeeds in starting with leftover UNIX domain socket bound" && {
64
+ test -S $unix_socket
65
+ unicorn -D -c $unix_config pid.ru
66
+ unicorn_wait_start
67
+ }
68
+
69
+ t_begin "worker pid changed" && {
70
+ test x"$(read_pid_unix)" != x$worker_pid
71
+ }
72
+
73
+ t_begin "killing succeeds" && {
74
+ kill $unicorn_pid
75
+ }
76
+
77
+ t_begin "no errors" && check_stderr
78
+
79
+ t_done
@@ -1,5 +1,5 @@
1
1
  . ./test-lib.sh
2
- RAILS_VERSION=${RAILS_VERSION-3.0.0.rc2}
2
+ RAILS_VERSION=${RAILS_VERSION-3.0.0}
3
3
  case $RUBY_VERSION in
4
4
  1.8.7|1.9.2) ;;
5
5
  *)
@@ -101,7 +101,14 @@ class TestSocketHelper < Test::Unit::TestCase
101
101
 
102
102
  def test_bind_listen_unix_rebind
103
103
  test_bind_listen_unix
104
- new_listener = bind_listen(@unix_listener_path)
104
+ new_listener = nil
105
+ assert_raises(Errno::EADDRINUSE) do
106
+ new_listener = bind_listen(@unix_listener_path)
107
+ end
108
+ assert_nothing_raised do
109
+ File.unlink(@unix_listener_path)
110
+ new_listener = bind_listen(@unix_listener_path)
111
+ end
105
112
  assert UNIXServer === new_listener
106
113
  assert new_listener.fileno != @unix_listener.fileno
107
114
  assert_equal sock_name(new_listener), sock_name(@unix_listener)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicorn
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 3
10
- version: 1.1.3
9
+ - 4
10
+ version: 1.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Unicorn hackers
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-28 00:00:00 +00:00
18
+ date: 2010-10-04 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -212,6 +212,7 @@ files:
212
212
  - t/t0007-working_directory_no_embed_cli.sh
213
213
  - t/t0008-back_out_of_upgrade.sh
214
214
  - t/t0009-winch_ttin.sh
215
+ - t/t0011-active-unix-socket.sh
215
216
  - t/t0300-rails3-basic.sh
216
217
  - t/t0301-rails3-missing-config-ru.sh
217
218
  - t/t0302-rails3-alt-working_directory.sh