yahns 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/GIT-VERSION-FILE +1 -1
- data/GIT-VERSION-GEN +1 -1
- data/NEWS +20 -0
- data/lib/yahns/http_client.rb +1 -1
- data/lib/yahns/http_response.rb +26 -1
- data/lib/yahns/socket_helper.rb +1 -5
- data/lib/yahns/version.rb +1 -1
- data/lib/yahns.rb +1 -0
- data/man/yahns-rackup.1 +57 -43
- data/man/yahns.1 +26 -19
- data/test/server_helper.rb +5 -0
- data/test/test_response.rb +84 -0
- data/yahns.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a9749686719fc4ebab52f18c57c3c3b9cf00ab8
|
4
|
+
data.tar.gz: 82df4e6686e4ee97cad0462fb1d0c809d19f9a10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5f385fabee64576cadcea538d77065ec625e50ee6c9c40ebba09d662995f6ad9c1740a422ee219078c1f1a7c7198120927625d08632b5d16d6f96dfd8039fb3
|
7
|
+
data.tar.gz: 12080fba5d268e326f648da62708ec2927063b2de470a3590be6d55d21968ea5150e94d8b18165dba22ca9388fbb535c9f5180039926a75df372d4f602d60c76
|
data/GIT-VERSION-FILE
CHANGED
@@ -1 +1 @@
|
|
1
|
-
VERSION = 1.
|
1
|
+
VERSION = 1.1.0
|
data/GIT-VERSION-GEN
CHANGED
data/NEWS
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
yahns 1.1.0 - MOAR SLEEPY / 2014-02-04
|
2
|
+
--------------------------------------
|
3
|
+
|
4
|
+
On responses with a known, non-zero Content-Length, yahns will now
|
5
|
+
automatically use the MSG_MORE flag when sending HTTP headers. This
|
6
|
+
reduces TCP packet transmits and allows clients to wake up and read
|
7
|
+
one less time.
|
8
|
+
|
9
|
+
This is similar to the TCP_NOPUSH/TCP_CORK functionality of other
|
10
|
+
servers, but requires no additional syscalls. It is only supported
|
11
|
+
on the Linux kernel, however (but yahns is currently epoll-only
|
12
|
+
with kqueue support on the horizon).
|
13
|
+
|
14
|
+
Eric Wong (5):
|
15
|
+
quiet down EHOSTUNREACH errors
|
16
|
+
http_response: use kgio_syssend with MSG_MORE
|
17
|
+
load yahns/version file
|
18
|
+
socket_helper: remove SO_REUSEPORT define for untested arches
|
19
|
+
response: do not use MSG_MORE on empty bodies
|
20
|
+
|
1
21
|
yahns 1.0.0 / 2014-01-02
|
2
22
|
------------------------
|
3
23
|
|
data/lib/yahns/http_client.rb
CHANGED
@@ -270,7 +270,7 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc:
|
|
270
270
|
def handle_error(e)
|
271
271
|
code = case e
|
272
272
|
when EOFError,Errno::ECONNRESET,Errno::EPIPE,Errno::ENOTCONN,
|
273
|
-
Errno::ETIMEDOUT
|
273
|
+
Errno::ETIMEDOUT,Errno::EHOSTUNREACH
|
274
274
|
return # don't send response, drop the connection
|
275
275
|
when Yahns::ClientTimeout
|
276
276
|
408
|
data/lib/yahns/http_response.rb
CHANGED
@@ -31,6 +31,22 @@ module Yahns::HttpResponse # :nodoc:
|
|
31
31
|
R100_RAW = "HTTP/1.1 100 Continue\r\n\r\n"
|
32
32
|
R100_CCC = "100 Continue\r\n\r\nHTTP/1.1 "
|
33
33
|
HTTP_EXPECT = "HTTP_EXPECT"
|
34
|
+
REQUEST_METHOD = "REQUEST_METHOD"
|
35
|
+
HEAD = "HEAD"
|
36
|
+
|
37
|
+
# no point in using one without the other, these have been in Linux
|
38
|
+
# for ages
|
39
|
+
if Socket.const_defined?(:MSG_MORE) && Socket.const_defined?(:MSG_DONTWAIT)
|
40
|
+
MSG_MORE = Socket::MSG_MORE
|
41
|
+
MSG_DONTWAIT = Socket::MSG_DONTWAIT
|
42
|
+
else
|
43
|
+
MSG_MORE = 0
|
44
|
+
MSG_DONTWAIT = 0
|
45
|
+
|
46
|
+
def kgio_syssend(buf, flags)
|
47
|
+
kgio_trywrite(buf)
|
48
|
+
end
|
49
|
+
end
|
34
50
|
|
35
51
|
def response_start
|
36
52
|
@response_start_sent ? Z : RESPONSE_START
|
@@ -109,6 +125,10 @@ module Yahns::HttpResponse # :nodoc:
|
|
109
125
|
end
|
110
126
|
end
|
111
127
|
|
128
|
+
def have_more?(value)
|
129
|
+
value.to_i > 0 && @hs.env[REQUEST_METHOD] != HEAD
|
130
|
+
end
|
131
|
+
|
112
132
|
# writes the rack_response to socket as an HTTP response
|
113
133
|
# returns :wait_readable, :wait_writable, :forget, or nil
|
114
134
|
def http_response_write(status, headers, body)
|
@@ -117,6 +137,7 @@ module Yahns::HttpResponse # :nodoc:
|
|
117
137
|
count = hijack = nil
|
118
138
|
k = self.class
|
119
139
|
alive = @hs.next? && k.persistent_connections
|
140
|
+
flags = MSG_DONTWAIT
|
120
141
|
|
121
142
|
if @hs.headers?
|
122
143
|
buf = "#{response_start}#{status}\r\nDate: #{httpdate}\r\n"
|
@@ -133,6 +154,9 @@ module Yahns::HttpResponse # :nodoc:
|
|
133
154
|
when %r{\AConnection\z}i
|
134
155
|
# allow Rack apps to tell us they want to drop the client
|
135
156
|
alive = false if value =~ /\bclose\b/i
|
157
|
+
when %r{\AContent-Length\z}i
|
158
|
+
flags |= MSG_MORE if have_more?(value)
|
159
|
+
buf << kv_str(key, value)
|
136
160
|
when "rack.hijack"
|
137
161
|
hijack = value
|
138
162
|
body = nil # ensure we do not close body
|
@@ -141,10 +165,11 @@ module Yahns::HttpResponse # :nodoc:
|
|
141
165
|
end
|
142
166
|
end
|
143
167
|
buf << (alive ? CONN_KA : CONN_CLOSE)
|
144
|
-
case rv =
|
168
|
+
case rv = kgio_syssend(buf, flags)
|
145
169
|
when nil # all done, likely
|
146
170
|
break
|
147
171
|
when String
|
172
|
+
flags = MSG_DONTWAIT
|
148
173
|
buf = rv # hope the skb grows
|
149
174
|
when :wait_writable, :wait_readable
|
150
175
|
if k.output_buffering
|
data/lib/yahns/socket_helper.rb
CHANGED
@@ -9,11 +9,7 @@ module Yahns::SocketHelper # :nodoc:
|
|
9
9
|
if defined?(Socket::SO_REUSEPORT)
|
10
10
|
Socket::SO_REUSEPORT
|
11
11
|
elsif RUBY_PLATFORM =~ /linux/
|
12
|
-
|
13
|
-
0x0200 # untested
|
14
|
-
else
|
15
|
-
15 # only tested on x86_64 and i686
|
16
|
-
end
|
12
|
+
15 # only tested on x86_64 and i686
|
17
13
|
else
|
18
14
|
nil
|
19
15
|
end
|
data/lib/yahns/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Yahns::VERSION = '1.
|
1
|
+
Yahns::VERSION = '1.1.0' # :nodoc:
|
data/lib/yahns.rb
CHANGED
data/man/yahns-rackup.1
CHANGED
@@ -12,42 +12,45 @@ It is expected to start in your application root (APP_ROOT).
|
|
12
12
|
.SH RACKUP FILE
|
13
13
|
.PP
|
14
14
|
This defaults to "config.ru" in APP_ROOT.
|
15
|
-
It should be the same file used by rackup(1) and other Rack
|
16
|
-
it uses the \f[I]Rack::Builder\f[] DSL.
|
15
|
+
It should be the same file used by rackup(1) and other Rack
|
16
|
+
launchers, it uses the \f[I]Rack::Builder\f[] DSL.
|
17
17
|
.SH YAHNS OPTIONS
|
18
18
|
.TP
|
19
19
|
.B -O client_timeout=SECONDS
|
20
20
|
Defines the timeout expiring idle connections.
|
21
21
|
.RS
|
22
22
|
.PP
|
23
|
-
Increase this if your application takes longer to run than the
|
24
|
-
timeout.
|
23
|
+
Increase this if your application takes longer to run than the
|
24
|
+
default timeout.
|
25
25
|
Lower this if you run out of FDs.
|
26
26
|
.PP
|
27
27
|
Default: 15 (seconds)
|
28
28
|
.RE
|
29
29
|
.TP
|
30
|
-
.B -O listen=ADDRESS[,ADDRESS
|
30
|
+
.B -O listen=ADDRESS[,ADDRESS\&...]
|
31
31
|
Listens on a given ADDRESS.
|
32
|
-
ADDRESS may be in the form of HOST:PORT or PATH, HOST:PORT is taken
|
33
|
-
mean a TCP socket and PATH is meant to be a path to a UNIX
|
34
|
-
socket.
|
35
|
-
Defaults to
|
32
|
+
ADDRESS may be in the form of HOST:PORT or PATH, HOST:PORT is taken
|
33
|
+
to mean a TCP socket and PATH is meant to be a path to a UNIX
|
34
|
+
domain socket.
|
35
|
+
Defaults to \[lq]0.0.0.0:9292\[rq] (all addresses on TCP port
|
36
|
+
9292).
|
36
37
|
Multiple addresses may be separated with commas.
|
37
38
|
.RS
|
38
39
|
.RE
|
39
40
|
.TP
|
40
41
|
.B -O stderr_path=PATHNAME
|
41
42
|
Allow redirecting $stderr to a given path.
|
42
|
-
Unlike doing this from the shell, this allows the yahns process to
|
43
|
-
the path its writing to and rotate the file if it is used for
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
Unlike doing this from the shell, this allows the yahns process to
|
44
|
+
know the path its writing to and rotate the file if it is used for
|
45
|
+
logging.
|
46
|
+
The file will be opened with the O_APPEND flag and writes
|
47
|
+
synchronized to the kernel (but not necessarily to \f[I]disk\f[])
|
48
|
+
so multiple processes can safely append to it.
|
47
49
|
.RS
|
48
50
|
.PP
|
49
|
-
If you are daemonizing and using the default logger, it is
|
50
|
-
specify this as errors will otherwise be lost to
|
51
|
+
If you are daemonizing and using the default logger, it is
|
52
|
+
important to specify this as errors will otherwise be lost to
|
53
|
+
/dev/null.
|
51
54
|
Some applications/libraries may also triggering warnings that go to
|
52
55
|
stderr, and they will end up here.
|
53
56
|
.PP
|
@@ -56,8 +59,8 @@ Default: /dev/null if daemonized, controlling terminal if not
|
|
56
59
|
.TP
|
57
60
|
.B -O stdout_path=PATH
|
58
61
|
Same as stderr_path, except for $stdout.
|
59
|
-
Not many applications write to $stdout, but any that do will have
|
60
|
-
output written here.
|
62
|
+
Not many applications write to $stdout, but any that do will have
|
63
|
+
their output written here.
|
61
64
|
It is safe to point this to the same location a stderr_path.
|
62
65
|
Like stderr_path, this defaults to /dev/null when daemonized.
|
63
66
|
.RS
|
@@ -68,9 +71,11 @@ Default: /dev/null if daemonized, controlling terminal if not
|
|
68
71
|
.B -O worker_threads=INTEGER
|
69
72
|
This controls the number of threads for application processing.
|
70
73
|
Each queue has its own thread pool.
|
71
|
-
Increase this number if your applications are able to use more
|
72
|
-
effectively or if either (or both) input/output buffering
|
73
|
-
|
74
|
+
Increase this number if your applications are able to use more
|
75
|
+
threads effectively or if either (or both) input/output buffering
|
76
|
+
are disabled.
|
77
|
+
Lower this number if you do not need multi-thread concurrency at
|
78
|
+
all.
|
74
79
|
.RS
|
75
80
|
.PP
|
76
81
|
Default: 7
|
@@ -81,8 +86,8 @@ Default: 7
|
|
81
86
|
Run daemonized in the background.
|
82
87
|
The process is detached from the controlling terminal and stdin is
|
83
88
|
redirected to /dev/null.
|
84
|
-
Unless specified via stderr_path and stdout_path, stderr and stdout
|
85
|
-
also be redirected to
|
89
|
+
Unless specified via stderr_path and stdout_path, stderr and stdout
|
90
|
+
will also be redirected to \[lq]/dev/null\[rq].
|
86
91
|
.RS
|
87
92
|
.RE
|
88
93
|
.TP
|
@@ -93,28 +98,31 @@ See the RACK ENVIRONMENT section for more details.
|
|
93
98
|
.RE
|
94
99
|
.TP
|
95
100
|
.B -o, --host HOST
|
96
|
-
Listen on a TCP socket belonging to HOST, default is
|
97
|
-
addresses).
|
98
|
-
If specified multiple times on the command-line, only the
|
99
|
-
value takes effect.
|
100
|
-
This option only exists for compatibility with the rackup(1)
|
101
|
-
use of
|
101
|
+
Listen on a TCP socket belonging to HOST, default is
|
102
|
+
\[lq]0.0.0.0\[rq] (all addresses).
|
103
|
+
If specified multiple times on the command-line, only the
|
104
|
+
last-specified value takes effect.
|
105
|
+
This option only exists for compatibility with the rackup(1)
|
106
|
+
command, use of \[lq]-l\[rq]/\[lq]--listen\[rq] switch is
|
107
|
+
recommended instead.
|
102
108
|
.RS
|
103
109
|
.RE
|
104
110
|
.TP
|
105
111
|
.B -p, --port PORT
|
106
112
|
Listen on the specified TCP PORT, default is 9292.
|
107
|
-
If specified multiple times on the command-line, only the
|
108
|
-
value takes effect.
|
109
|
-
This option only exists for compatibility with the rackup(1)
|
110
|
-
use of
|
113
|
+
If specified multiple times on the command-line, only the
|
114
|
+
last-specified value takes effect.
|
115
|
+
This option only exists for compatibility with the rackup(1)
|
116
|
+
command, use of \[lq]-l\[rq]/\[lq]--listen\[rq] switch is
|
117
|
+
recommended instead.
|
111
118
|
.RS
|
112
119
|
.RE
|
113
120
|
.SH RUBY OPTIONS
|
114
121
|
.TP
|
115
122
|
.B -e, --eval LINE
|
116
123
|
Evaluate a LINE of Ruby code.
|
117
|
-
This evaluation happens immediately as the command-line is being
|
124
|
+
This evaluation happens immediately as the command-line is being
|
125
|
+
parsed.
|
118
126
|
.RS
|
119
127
|
.RE
|
120
128
|
.TP
|
@@ -131,17 +139,18 @@ Turn on verbose warnings, the $VERBOSE variable is set to true.
|
|
131
139
|
.B -I, --include PATH
|
132
140
|
specify $LOAD_PATH.
|
133
141
|
PATH will be prepended to $LOAD_PATH.
|
134
|
-
The \[aq]:\[aq] character may be used to delimit multiple
|
142
|
+
The \[aq]:\[aq] character may be used to delimit multiple
|
143
|
+
directories.
|
135
144
|
This directive may be used more than once.
|
136
|
-
Modifications to $LOAD_PATH take place immediately and in the order
|
137
|
-
were specified on the command-line.
|
145
|
+
Modifications to $LOAD_PATH take place immediately and in the order
|
146
|
+
they were specified on the command-line.
|
138
147
|
.RS
|
139
148
|
.RE
|
140
149
|
.TP
|
141
150
|
.B -r, --require LIBRARY
|
142
151
|
require a specified LIBRARY before executing the application.
|
143
|
-
The "require" statement will be executed immediately and in the
|
144
|
-
they were specified on the command-line.
|
152
|
+
The "require" statement will be executed immediately and in the
|
153
|
+
order they were specified on the command-line.
|
145
154
|
.RS
|
146
155
|
.RE
|
147
156
|
.SH SIGNALS
|
@@ -157,18 +166,22 @@ If RACK_ENV is already set, it will be used unless -E is used.
|
|
157
166
|
See rackup documentation for more details.
|
158
167
|
.SH CONTACT
|
159
168
|
.PP
|
160
|
-
All feedback welcome via plain-text mail to
|
169
|
+
All feedback welcome via plain-text mail to
|
170
|
+
<yahns-public@rubyforge.org>
|
161
171
|
.PD 0
|
162
172
|
.P
|
163
173
|
.PD
|
164
|
-
No subscription is
|
174
|
+
No subscription is
|
175
|
+
necessary to post to the mailing list.
|
165
176
|
.SH COPYRIGHT
|
166
177
|
.PP
|
167
|
-
Copyright 2013, Eric Wong <normalperson@yhbt.net> and all
|
178
|
+
Copyright 2013, Eric Wong <normalperson@yhbt.net> and all
|
179
|
+
contributors.
|
168
180
|
.PD 0
|
169
181
|
.P
|
170
182
|
.PD
|
171
|
-
License: GPLv3 or later
|
183
|
+
License: GPLv3 or later
|
184
|
+
<http://www.gnu.org/licenses/gpl-3.0.txt>
|
172
185
|
.SH SEE ALSO
|
173
186
|
.PP
|
174
187
|
yahns(1), yahns_config(5)
|
@@ -178,3 +191,4 @@ yahns(1), yahns_config(5)
|
|
178
191
|
Rack RDoc (http://rack.rubyforge.org/doc/)
|
179
192
|
.IP \[bu] 2
|
180
193
|
Rackup HowTo (http://wiki.github.com/rack/rack/tutorial-rackup-howto)
|
194
|
+
|
data/man/yahns.1
CHANGED
@@ -4,19 +4,20 @@
|
|
4
4
|
yahns - multi-threaded, non-blocking application server for Ruby
|
5
5
|
.SH SYNOPSYS
|
6
6
|
.PP
|
7
|
-
yahns -c CONFIG_FILE [-D
|
7
|
+
yahns -c CONFIG_FILE [-D|\[em]daemonize]
|
8
8
|
.SH DESCRIPTION
|
9
9
|
.PP
|
10
10
|
yahns(1) is the primary interface for launching a yahns application
|
11
11
|
server.
|
12
12
|
The configuration file is documented in yahns_config(5).
|
13
|
-
yahns hosts Rack HTTP applications, but may support others in the
|
14
|
-
such as DRb.
|
13
|
+
yahns hosts Rack HTTP applications, but may support others in the
|
14
|
+
future such as DRb.
|
15
15
|
.SH SIGNALS
|
16
16
|
.PP
|
17
|
-
The following UNIX signals may be sent to the running yahns
|
18
|
-
|
19
|
-
|
17
|
+
The following UNIX signals may be sent to the running yahns
|
18
|
+
process.
|
19
|
+
If yahns is configured for worker_processes (optional), signals
|
20
|
+
should only be sent to the master process.
|
20
21
|
.IP \[bu] 2
|
21
22
|
INT/TERM/QUIT - graceful shutdown.
|
22
23
|
If repeated (any of these signals is sent twice), shutdown occurs
|
@@ -29,10 +30,10 @@ O_APPEND file flag and buffering disabled (IO#sync==false)
|
|
29
30
|
USR2 - reexecute the running binary.
|
30
31
|
A separate QUIT should be sent to
|
31
32
|
.IP \[bu] 2
|
32
|
-
HUP - if worker_processes are not used, this will reexecute the
|
33
|
-
binary and gracefully exit the running process.
|
34
|
-
If worker_processes are used, this will reload config file, app,
|
35
|
-
gracefully restart all workers
|
33
|
+
HUP - if worker_processes are not used, this will reexecute the
|
34
|
+
running binary and gracefully exit the running process.
|
35
|
+
If worker_processes are used, this will reload config file, app,
|
36
|
+
and gracefully restart all workers
|
36
37
|
.IP \[bu] 2
|
37
38
|
WINCH - gracefully stops workers but keep the master running.
|
38
39
|
This will only work for daemonized processes and only if the
|
@@ -46,30 +47,36 @@ worker_processes directive is used)
|
|
46
47
|
.SH ENVIRONMENT
|
47
48
|
.PP
|
48
49
|
yahns(1) itself requires no special environment variables.
|
49
|
-
However, environment variables such as RACK_ENV and RAILS_ENV can
|
50
|
-
Rack and Rails applications it hosts.
|
51
|
-
Ruby and C library implementation-specific environment variables
|
52
|
-
also affect it.
|
50
|
+
However, environment variables such as RACK_ENV and RAILS_ENV can
|
51
|
+
affect Rack and Rails applications it hosts.
|
52
|
+
Ruby and C library implementation-specific environment variables
|
53
|
+
will also affect it.
|
53
54
|
.PP
|
54
55
|
yahns will update the PWD (current working directory) env if the
|
55
56
|
working_directory directive is set (see yahns_config(5)).
|
56
57
|
.SH FILES
|
57
58
|
.PP
|
58
|
-
See yahns_config(5) for documentation on the configuration file
|
59
|
+
See yahns_config(5) for documentation on the configuration file
|
60
|
+
format.
|
59
61
|
.SH CONTACT
|
60
62
|
.PP
|
61
|
-
All feedback welcome via plain-text mail to
|
63
|
+
All feedback welcome via plain-text mail to
|
64
|
+
<yahns-public@rubyforge.org>
|
62
65
|
.PD 0
|
63
66
|
.P
|
64
67
|
.PD
|
65
|
-
No subscription is
|
68
|
+
No subscription is
|
69
|
+
necessary to post to the mailing list.
|
66
70
|
.SH COPYRIGHT
|
67
71
|
.PP
|
68
|
-
Copyright 2013, Eric Wong <normalperson@yhbt.net> and all
|
72
|
+
Copyright 2013, Eric Wong <normalperson@yhbt.net> and all
|
73
|
+
contributors.
|
69
74
|
.PD 0
|
70
75
|
.P
|
71
76
|
.PD
|
72
|
-
License: GPLv3 or later
|
77
|
+
License: GPLv3 or later
|
78
|
+
<http://www.gnu.org/licenses/gpl-3.0.txt>
|
73
79
|
.SH SEE ALSO
|
74
80
|
.PP
|
75
81
|
yahns-rackup(1), yahns_config(5)
|
82
|
+
|
data/test/server_helper.rb
CHANGED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
|
2
|
+
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
|
3
|
+
require_relative 'server_helper'
|
4
|
+
|
5
|
+
class TestResponse < Testcase
|
6
|
+
ENV["N"].to_i > 1 and parallelize_me!
|
7
|
+
include ServerHelper
|
8
|
+
alias setup server_helper_setup
|
9
|
+
alias teardown server_helper_teardown
|
10
|
+
|
11
|
+
def test_response_time_empty_body
|
12
|
+
err = @err
|
13
|
+
cfg = Yahns::Config.new
|
14
|
+
host, port = @srv.addr[3], @srv.addr[1]
|
15
|
+
cfg.instance_eval do
|
16
|
+
GTL.synchronize do
|
17
|
+
app = Rack::Builder.new do
|
18
|
+
use Rack::ContentLength
|
19
|
+
use Rack::ContentType, "text/plain"
|
20
|
+
run lambda { |_| [ 200, {}, [] ] }
|
21
|
+
end
|
22
|
+
app(:rack, app) do
|
23
|
+
listen "#{host}:#{port}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
logger(Logger.new(err.path))
|
27
|
+
end
|
28
|
+
pid = mkserver(cfg)
|
29
|
+
Net::HTTP.start(host, port) { |h|
|
30
|
+
# warmup request
|
31
|
+
res = h.get("/")
|
32
|
+
assert_empty res.body
|
33
|
+
|
34
|
+
t0 = Time.now
|
35
|
+
nr = 10
|
36
|
+
nr.times do
|
37
|
+
res = h.get("/")
|
38
|
+
assert_empty res.body
|
39
|
+
end
|
40
|
+
diff = Time.now - t0
|
41
|
+
assert_operator diff, :<, (0.200 * nr)
|
42
|
+
}
|
43
|
+
ensure
|
44
|
+
quit_wait(pid)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_response_time_head
|
48
|
+
err = @err
|
49
|
+
cfg = Yahns::Config.new
|
50
|
+
host, port = @srv.addr[3], @srv.addr[1]
|
51
|
+
cfg.instance_eval do
|
52
|
+
GTL.synchronize do
|
53
|
+
require 'rack/lobster'
|
54
|
+
app = Rack::Builder.new do
|
55
|
+
use Rack::Head
|
56
|
+
use Rack::ContentLength
|
57
|
+
use Rack::ContentType, "text/plain"
|
58
|
+
run Rack::Lobster.new
|
59
|
+
end
|
60
|
+
app(:rack, app) do
|
61
|
+
listen "#{host}:#{port}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
logger(Logger.new(err.path))
|
65
|
+
end
|
66
|
+
pid = mkserver(cfg)
|
67
|
+
Net::HTTP.start(host, port) { |h|
|
68
|
+
# warmup request
|
69
|
+
res = h.head("/")
|
70
|
+
assert_equal 200, res.code.to_i
|
71
|
+
|
72
|
+
t0 = Time.now
|
73
|
+
nr = 10
|
74
|
+
nr.times do
|
75
|
+
res = h.head("/")
|
76
|
+
assert_equal 200, res.code.to_i
|
77
|
+
end
|
78
|
+
diff = Time.now - t0
|
79
|
+
assert_operator diff, :<, (0.200 * nr)
|
80
|
+
}
|
81
|
+
ensure
|
82
|
+
quit_wait(pid)
|
83
|
+
end
|
84
|
+
end
|
data/yahns.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.email = %q{yahns@yhbt.net}
|
11
11
|
s.executables = manifest.grep(%r{\Abin/}).map { |s| s.sub(%r{\Abin/}, "") }
|
12
12
|
s.files = manifest
|
13
|
-
s.add_dependency(%q<kgio>, '~> 2.
|
13
|
+
s.add_dependency(%q<kgio>, '~> 2.9')
|
14
14
|
s.add_dependency(%q<sleepy_penguin>, '~> 3.2')
|
15
15
|
s.add_dependency(%q<sendfile>, '~> 1.2.1')
|
16
16
|
s.add_dependency(%q<unicorn>, '~> 4.6', '>= 4.6.3')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yahns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yahns hackers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kgio
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.9'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.9'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sleepy_penguin
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,6 +196,7 @@ files:
|
|
196
196
|
- test/test_rack.rb
|
197
197
|
- test/test_rack_hijack.rb
|
198
198
|
- test/test_reopen_logs.rb
|
199
|
+
- test/test_response.rb
|
199
200
|
- test/test_serve_static.rb
|
200
201
|
- test/test_server.rb
|
201
202
|
- test/test_stream_file.rb
|