unicorn 4.6.2 → 4.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/GIT-VERSION-GEN +1 -1
- data/examples/nginx.conf +4 -4
- data/examples/unicorn.conf.rb +1 -1
- data/ext/unicorn_http/unicorn_http.rl +2 -4
- data/lib/unicorn.rb +5 -1
- data/lib/unicorn/configurator.rb +8 -2
- data/t/fails-rack-lint.ru +5 -0
- data/t/t0300-no-default-middleware.sh +15 -0
- data/test/unit/test_http_parser_ng.rb +17 -0
- data/test/unit/test_signals.rb +1 -1
- metadata +4 -2
data/GIT-VERSION-GEN
CHANGED
data/examples/nginx.conf
CHANGED
@@ -24,8 +24,8 @@ user nobody nogroup; # for systems with a "nogroup"
|
|
24
24
|
# user nobody nobody; # for systems with "nobody" as a group instead
|
25
25
|
|
26
26
|
# Feel free to change all paths to suite your needs here, of course
|
27
|
-
pid /
|
28
|
-
error_log /
|
27
|
+
pid /path/to/nginx.pid;
|
28
|
+
error_log /path/to/nginx.error.log;
|
29
29
|
|
30
30
|
events {
|
31
31
|
worker_connections 1024; # increase if you have lots of clients
|
@@ -42,7 +42,7 @@ http {
|
|
42
42
|
default_type application/octet-stream;
|
43
43
|
|
44
44
|
# click tracking!
|
45
|
-
access_log /
|
45
|
+
access_log /path/to/nginx.access.log combined;
|
46
46
|
|
47
47
|
# you generally want to serve static files with nginx since neither
|
48
48
|
# Unicorn nor Rainbows! is optimized for it at the moment
|
@@ -74,7 +74,7 @@ http {
|
|
74
74
|
# single worker for timing out).
|
75
75
|
|
76
76
|
# for UNIX domain socket setups:
|
77
|
-
server unix:/
|
77
|
+
server unix:/path/to/.unicorn.sock fail_timeout=0;
|
78
78
|
|
79
79
|
# for TCP setups, point these to your backend servers
|
80
80
|
# server 192.168.0.7:8080 fail_timeout=0;
|
data/examples/unicorn.conf.rb
CHANGED
@@ -25,7 +25,7 @@ working_directory "/path/to/app/current" # available in 0.94.0+
|
|
25
25
|
|
26
26
|
# listen on both a Unix domain socket and a TCP port,
|
27
27
|
# we use a shorter backlog for quicker failover when busy
|
28
|
-
listen "/
|
28
|
+
listen "/path/to/.unicorn.sock", :backlog => 64
|
29
29
|
listen 8080, :tcp_nopush => true
|
30
30
|
|
31
31
|
# nuke workers after 30 seconds instead of 60 seconds (the default)
|
@@ -732,10 +732,8 @@ static VALUE HttpParser_parse(VALUE self)
|
|
732
732
|
struct http_parser *hp = data_get(self);
|
733
733
|
VALUE data = hp->buf;
|
734
734
|
|
735
|
-
if (HP_FL_TEST(hp, TO_CLEAR))
|
736
|
-
|
737
|
-
rb_funcall(hp->env, id_clear, 0);
|
738
|
-
}
|
735
|
+
if (HP_FL_TEST(hp, TO_CLEAR))
|
736
|
+
HttpParser_clear(self);
|
739
737
|
|
740
738
|
http_parser_execute(hp, RSTRING_PTR(data), RSTRING_LEN(data));
|
741
739
|
if (hp->offset > MAX_HEADER_LEN)
|
data/lib/unicorn.rb
CHANGED
@@ -35,6 +35,10 @@ module Unicorn
|
|
35
35
|
# allow Configurator to parse cli switches embedded in the ru file
|
36
36
|
op = Unicorn::Configurator::RACKUP.merge!(:file => ru, :optparse => op)
|
37
37
|
|
38
|
+
# Op is going to get cleared before the returned lambda is called, so
|
39
|
+
# save this value so that it's still there when we need it:
|
40
|
+
no_default_middleware = op[:no_default_middleware]
|
41
|
+
|
38
42
|
# always called after config file parsing, may be called after forking
|
39
43
|
lambda do ||
|
40
44
|
inner_app = case ru
|
@@ -49,7 +53,7 @@ module Unicorn
|
|
49
53
|
|
50
54
|
pp({ :inner_app => inner_app }) if $DEBUG
|
51
55
|
|
52
|
-
return inner_app if
|
56
|
+
return inner_app if no_default_middleware
|
53
57
|
|
54
58
|
# return value, matches rackup defaults based on env
|
55
59
|
# Unicorn does not support persistent connections, but Rainbows!
|
data/lib/unicorn/configurator.rb
CHANGED
@@ -188,7 +188,7 @@ class Unicorn::Configurator
|
|
188
188
|
# # on nginx upstream configuration:
|
189
189
|
# upstream unicorn_backend {
|
190
190
|
# # for UNIX domain socket setups:
|
191
|
-
# server unix:/path/to
|
191
|
+
# server unix:/path/to/.unicorn.sock fail_timeout=0;
|
192
192
|
#
|
193
193
|
# # for TCP setups
|
194
194
|
# server 192.168.0.7:8080 fail_timeout=0;
|
@@ -229,9 +229,15 @@ class Unicorn::Configurator
|
|
229
229
|
#
|
230
230
|
# listen 3000 # listen to port 3000 on all TCP interfaces
|
231
231
|
# listen "127.0.0.1:3000" # listen to port 3000 on the loopback interface
|
232
|
-
# listen "/
|
232
|
+
# listen "/path/to/.unicorn.sock" # listen on the given Unix domain socket
|
233
233
|
# listen "[::1]:3000" # listen to port 3000 on the IPv6 loopback interface
|
234
234
|
#
|
235
|
+
# When using Unix domain sockets, be sure:
|
236
|
+
# 1) the path matches the one used by nginx
|
237
|
+
# 2) uses the same filesystem namespace as the nginx process
|
238
|
+
# For systemd users using PrivateTmp=true (for either nginx or unicorn),
|
239
|
+
# this means Unix domain sockets must not be placed in /tmp
|
240
|
+
#
|
235
241
|
# The following options may be specified (but are generally not needed):
|
236
242
|
#
|
237
243
|
# [:backlog => number of clients]
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# This rack app returns an invalid status code, which will cause
|
2
|
+
# Rack::Lint to throw an exception if it is present. This
|
3
|
+
# is used to check whether Rack::Lint is in the stack or not.
|
4
|
+
|
5
|
+
run lambda {|env| return [42, {}, ["Rack::Lint wasn't there if you see this"]]}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
. ./test-lib.sh
|
3
|
+
t_plan 2 "test the -N / --no-default-middleware option"
|
4
|
+
|
5
|
+
t_begin "setup and start" && {
|
6
|
+
unicorn_setup
|
7
|
+
unicorn -N -D -c $unicorn_config fails-rack-lint.ru
|
8
|
+
unicorn_wait_start
|
9
|
+
}
|
10
|
+
|
11
|
+
t_begin "check exit status with Rack::Lint not present" && {
|
12
|
+
test 42 -eq "$(curl -sf -o/dev/null -w'%{http_code}' http://$listen/)"
|
13
|
+
}
|
14
|
+
|
15
|
+
t_done
|
@@ -12,6 +12,23 @@ class HttpParserNgTest < Test::Unit::TestCase
|
|
12
12
|
@parser = HttpParser.new
|
13
13
|
end
|
14
14
|
|
15
|
+
def test_next_clear
|
16
|
+
r = "GET / HTTP/1.1\r\nHost: example.com\r\n\r\n"
|
17
|
+
@parser.buf << r
|
18
|
+
@parser.parse
|
19
|
+
@parser.response_start_sent = true
|
20
|
+
assert @parser.keepalive?
|
21
|
+
assert @parser.next?
|
22
|
+
assert @parser.response_start_sent
|
23
|
+
|
24
|
+
# persistent client makes another request:
|
25
|
+
@parser.buf << r
|
26
|
+
@parser.parse
|
27
|
+
assert @parser.keepalive?
|
28
|
+
assert @parser.next?
|
29
|
+
assert_equal false, @parser.response_start_sent
|
30
|
+
end
|
31
|
+
|
15
32
|
def test_keepalive_requests_default_constant
|
16
33
|
assert_kind_of Integer, HttpParser::KEEPALIVE_REQUESTS_DEFAULT
|
17
34
|
assert HttpParser::KEEPALIVE_REQUESTS_DEFAULT >= 0
|
data/test/unit/test_signals.rb
CHANGED
@@ -174,7 +174,7 @@ class SignalsTest < Test::Unit::TestCase
|
|
174
174
|
sock.syswrite("Content-Length: #{@bs * @count}\r\n\r\n")
|
175
175
|
1000.times { Process.kill(:HUP, pid) }
|
176
176
|
size_before = @tmp.stat.size
|
177
|
-
killer = fork { loop { Process.kill(:HUP, pid); sleep(0.
|
177
|
+
killer = fork { loop { Process.kill(:HUP, pid); sleep(0.01) } }
|
178
178
|
buf = ' ' * @bs
|
179
179
|
@count.times { sock.syswrite(buf) }
|
180
180
|
Process.kill(:KILL, killer)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: !binary |-
|
3
3
|
dW5pY29ybg==
|
4
4
|
version: !ruby/object:Gem::Version
|
5
|
-
version: 4.6.
|
5
|
+
version: 4.6.3
|
6
6
|
prerelease:
|
7
7
|
platform: ruby
|
8
8
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-06-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: !binary |-
|
@@ -254,6 +254,7 @@ files:
|
|
254
254
|
- t/broken-app.ru
|
255
255
|
- t/detach.ru
|
256
256
|
- t/env.ru
|
257
|
+
- t/fails-rack-lint.ru
|
257
258
|
- t/heartbeat-timeout.ru
|
258
259
|
- t/hijack.ru
|
259
260
|
- t/listener_names.ru
|
@@ -297,6 +298,7 @@ files:
|
|
297
298
|
- t/t0116-client_body_buffer_size.sh
|
298
299
|
- t/t0116.ru
|
299
300
|
- t/t0200-rack-hijack.sh
|
301
|
+
- t/t0300-no-default-middleware.sh
|
300
302
|
- t/t0600-https-server-basic.sh
|
301
303
|
- t/t9000-preread-input.sh
|
302
304
|
- t/t9001-oob_gc.sh
|