yahns 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Documentation/.gitignore +5 -0
- data/Documentation/GNUmakefile +50 -0
- data/Documentation/yahns-rackup.txt +152 -0
- data/Documentation/yahns.txt +68 -0
- data/Documentation/yahns_config.txt +563 -0
- data/GIT-VERSION-GEN +1 -1
- data/GNUmakefile +14 -7
- data/HACKING +56 -0
- data/INSTALL +8 -0
- data/README +15 -2
- data/Rakefile +2 -2
- data/bin/yahns +1 -2
- data/bin/yahns-rackup +9 -0
- data/examples/yahns_multi.conf.rb +14 -4
- data/examples/yahns_rack_basic.conf.rb +17 -1
- data/extras/README +16 -0
- data/extras/autoindex.rb +151 -0
- data/extras/exec_cgi.rb +108 -0
- data/extras/proxy_pass.rb +210 -0
- data/extras/try_gzip_static.rb +208 -0
- data/lib/yahns.rb +5 -2
- data/lib/yahns/acceptor.rb +64 -22
- data/lib/yahns/cap_input.rb +2 -2
- data/lib/yahns/{client_expire_portable.rb → client_expire_generic.rb} +12 -11
- data/lib/yahns/{client_expire.rb → client_expire_tcpi.rb} +7 -6
- data/lib/yahns/config.rb +107 -22
- data/lib/yahns/daemon.rb +2 -0
- data/lib/yahns/fdmap.rb +28 -9
- data/lib/yahns/http_client.rb +123 -37
- data/lib/yahns/http_context.rb +21 -3
- data/lib/yahns/http_response.rb +80 -19
- data/lib/yahns/log.rb +23 -4
- data/lib/yahns/queue_epoll.rb +20 -9
- data/lib/yahns/queue_quitter.rb +16 -0
- data/lib/yahns/queue_quitter_pipe.rb +24 -0
- data/lib/yahns/rack.rb +0 -1
- data/lib/yahns/rackup_handler.rb +57 -0
- data/lib/yahns/server.rb +189 -59
- data/lib/yahns/server_mp.rb +43 -35
- data/lib/yahns/sigevent_pipe.rb +1 -0
- data/lib/yahns/socket_helper.rb +37 -11
- data/lib/yahns/stream_file.rb +14 -4
- data/lib/yahns/stream_input.rb +13 -7
- data/lib/yahns/tcp_server.rb +7 -0
- data/lib/yahns/tmpio.rb +10 -3
- data/lib/yahns/unix_server.rb +7 -0
- data/lib/yahns/wbuf.rb +19 -2
- data/lib/yahns/wbuf_common.rb +10 -3
- data/lib/yahns/wbuf_str.rb +24 -0
- data/lib/yahns/worker.rb +5 -26
- data/test/helper.rb +15 -5
- data/test/server_helper.rb +37 -1
- data/test/test_bin.rb +17 -8
- data/test/test_buffer_tmpdir.rb +103 -0
- data/test/test_client_expire.rb +71 -35
- data/test/test_client_max_body_size.rb +5 -13
- data/test/test_config.rb +1 -1
- data/test/test_expect_100.rb +176 -0
- data/test/test_extras_autoindex.rb +53 -0
- data/test/test_extras_exec_cgi.rb +81 -0
- data/test/test_extras_exec_cgi.sh +35 -0
- data/test/test_extras_try_gzip_static.rb +177 -0
- data/test/test_input.rb +128 -0
- data/test/test_mt_accept.rb +48 -0
- data/test/test_output_buffering.rb +90 -63
- data/test/test_rack.rb +1 -1
- data/test/test_rack_hijack.rb +2 -6
- data/test/test_reopen_logs.rb +2 -8
- data/test/test_serve_static.rb +104 -8
- data/test/test_server.rb +448 -73
- data/test/test_stream_file.rb +1 -1
- data/test/test_unix_socket.rb +72 -0
- data/test/test_wbuf.rb +20 -17
- data/yahns.gemspec +3 -0
- metadata +57 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32f85a4c4ed36a082242c5b58bae7f18528543c1
|
4
|
+
data.tar.gz: e741b37a8b0f62d47d9ea08ce36ab69b31536f15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8eb0d76f793c6bc787ec789214e05f2f03face6e7772cad38ca7da67986e6a579f9b69c927ed39224b75f72e2dafaa3f886a4dc9c17eea24ccd0d3ae59aaf994
|
7
|
+
data.tar.gz: d9b233d340ef2ca35c5f5c085cac97bb6090d3ba2dbf2c89b57edcc1577d6ea5ef8b67f4821f6cbe04e36938b9d49ebd6d8898838f370baeb89da1845297bbe5
|
data/.gitignore
CHANGED
@@ -0,0 +1,50 @@
|
|
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
|
+
all::
|
4
|
+
|
5
|
+
INSTALL = install
|
6
|
+
PANDOC = pandoc
|
7
|
+
PANDOC_OPTS = -f markdown --email-obfuscation=none
|
8
|
+
pandoc = $(PANDOC) $(PANDOC_OPTS)
|
9
|
+
|
10
|
+
m1 =
|
11
|
+
m1 += yahns
|
12
|
+
m1 += yahns-rackup
|
13
|
+
|
14
|
+
m5 =
|
15
|
+
m5 += yahns_config
|
16
|
+
|
17
|
+
m7 =
|
18
|
+
|
19
|
+
man1 := $(addsuffix .1, $(m1))
|
20
|
+
man5 := $(addsuffix .5, $(m5))
|
21
|
+
man7 := $(addsuffix .7, $(m7))
|
22
|
+
|
23
|
+
all:: man
|
24
|
+
|
25
|
+
man: $(man1) $(man5) $(man7)
|
26
|
+
|
27
|
+
prefix ?= $(HOME)
|
28
|
+
mandir ?= $(prefix)/share/man
|
29
|
+
man1dir = $(mandir)/man1
|
30
|
+
man5dir = $(mandir)/man5
|
31
|
+
man7dir = $(mandir)/man7
|
32
|
+
|
33
|
+
gem-man: man
|
34
|
+
$(INSTALL) -d -m 755 ../man
|
35
|
+
$(INSTALL) -m 644 $(man1) ../man
|
36
|
+
$(INSTALL) -m 644 $(man5) ../man
|
37
|
+
test -z "$(man7)" || $(INSTALL) -m 644 $(man7) ../man
|
38
|
+
|
39
|
+
install-man: man
|
40
|
+
$(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
|
41
|
+
$(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
|
42
|
+
test -z "$(man7)" || $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
|
43
|
+
$(INSTALL) -m 644 $(man1) $(DESTDIR)$(man1dir)
|
44
|
+
$(INSTALL) -m 644 $(man5) $(DESTDIR)$(man5dir)
|
45
|
+
test -z "$(man7)" || $(INSTALL) -m 644 $(man7) $(DESTDIR)$(man7dir)
|
46
|
+
%.1 %.5 %.7 : %.txt
|
47
|
+
$(pandoc) -s -t man < $< > $@+ && mv $@+ $@
|
48
|
+
|
49
|
+
clean::
|
50
|
+
$(RM) $(man1) $(man5) $(man7)
|
@@ -0,0 +1,152 @@
|
|
1
|
+
% yahns-rackup(1) yahns user manual
|
2
|
+
|
3
|
+
# NAME
|
4
|
+
|
5
|
+
yahns-rackup - a rackup-like command to launch yahns
|
6
|
+
|
7
|
+
# SYNOPSIS
|
8
|
+
|
9
|
+
yahns-rackup [-E RACK_ENV] [-O worker_threads=NUM] [RACKUP_FILE]
|
10
|
+
|
11
|
+
# DESCRIPTION
|
12
|
+
|
13
|
+
A rackup(1)-like command to launch Rack applications using yahns.
|
14
|
+
It is expected to start in your application root (APP_ROOT).
|
15
|
+
|
16
|
+
# RACKUP FILE
|
17
|
+
|
18
|
+
This defaults to \"config.ru\" in APP_ROOT. It should be the same
|
19
|
+
file used by rackup(1) and other Rack launchers, it uses the
|
20
|
+
*Rack::Builder* DSL.
|
21
|
+
|
22
|
+
# YAHNS OPTIONS
|
23
|
+
-O client_timeout=SECONDS
|
24
|
+
: Defines the timeout expiring idle connections.
|
25
|
+
|
26
|
+
Increase this if your application takes longer to run than the
|
27
|
+
default timeout. Lower this if you run out of FDs.
|
28
|
+
|
29
|
+
Default: 15 (seconds)
|
30
|
+
|
31
|
+
-O listen=ADDRESS[,ADDRESS...]
|
32
|
+
: Listens on a given ADDRESS. ADDRESS may be in the form of
|
33
|
+
HOST:PORT or PATH, HOST:PORT is taken to mean a TCP socket
|
34
|
+
and PATH is meant to be a path to a UNIX domain socket.
|
35
|
+
Defaults to "0.0.0.0:9292" (all addresses on TCP port 9292).
|
36
|
+
Multiple addresses may be separated with commas.
|
37
|
+
|
38
|
+
-O stderr_path=PATHNAME
|
39
|
+
: Allow redirecting $stderr to a given path. Unlike doing this from
|
40
|
+
the shell, this allows the yahns process to know the path its
|
41
|
+
writing to and rotate the file if it is used for logging. The
|
42
|
+
file will be opened with the O_APPEND flag and writes
|
43
|
+
synchronized to the kernel (but not necessarily to _disk_) so
|
44
|
+
multiple processes can safely append to it.
|
45
|
+
|
46
|
+
If you are daemonizing and using the default logger, it is important
|
47
|
+
to specify this as errors will otherwise be lost to /dev/null.
|
48
|
+
Some applications/libraries may also triggering warnings that go to
|
49
|
+
stderr, and they will end up here.
|
50
|
+
|
51
|
+
Default: /dev/null if daemonized, controlling terminal if not
|
52
|
+
|
53
|
+
-O stdout_path=PATH
|
54
|
+
: Same as stderr_path, except for $stdout. Not many applications
|
55
|
+
write to $stdout, but any that do will have their output written here.
|
56
|
+
It is safe to point this to the same location a stderr_path.
|
57
|
+
Like stderr_path, this defaults to /dev/null when daemonized.
|
58
|
+
|
59
|
+
Default: /dev/null if daemonized, controlling terminal if not
|
60
|
+
|
61
|
+
-O worker_threads=INTEGER
|
62
|
+
: This controls the number of threads for application processing.
|
63
|
+
Each queue has its own thread pool. Increase this number if your
|
64
|
+
applications are able to use more threads effectively or if either
|
65
|
+
(or both) input/output buffering are disabled. Lower this number if
|
66
|
+
you do not need multi-thread concurrency at all.
|
67
|
+
|
68
|
+
Default: 7
|
69
|
+
|
70
|
+
# RACKUP OPTIONS
|
71
|
+
-D, \--daemonize
|
72
|
+
: Run daemonized in the background. The process is detached from
|
73
|
+
the controlling terminal and stdin is redirected to /dev/null.
|
74
|
+
Unless specified via stderr_path and stdout_path, stderr and stdout will
|
75
|
+
also be redirected to "/dev/null".
|
76
|
+
|
77
|
+
-E, \--env RACK_ENV
|
78
|
+
: Run under the given RACK_ENV. See the RACK ENVIRONMENT section
|
79
|
+
for more details.
|
80
|
+
|
81
|
+
-o, \--host HOST
|
82
|
+
: Listen on a TCP socket belonging to HOST, default is
|
83
|
+
"0.0.0.0" (all addresses).
|
84
|
+
If specified multiple times on the command-line, only the
|
85
|
+
last-specified value takes effect.
|
86
|
+
This option only exists for compatibility with the rackup(1) command,
|
87
|
+
use of "-l"/"\--listen" switch is recommended instead.
|
88
|
+
|
89
|
+
-p, \--port PORT
|
90
|
+
: Listen on the specified TCP PORT, default is 9292.
|
91
|
+
If specified multiple times on the command-line, only the last-specified
|
92
|
+
value takes effect.
|
93
|
+
This option only exists for compatibility with the rackup(1) command,
|
94
|
+
use of "-l"/"\--listen" switch is recommended instead.
|
95
|
+
|
96
|
+
# RUBY OPTIONS
|
97
|
+
-e, \--eval LINE
|
98
|
+
: Evaluate a LINE of Ruby code. This evaluation happens
|
99
|
+
immediately as the command-line is being parsed.
|
100
|
+
|
101
|
+
-d, \--debug
|
102
|
+
: Turn on debug mode, the $DEBUG variable is set to true.
|
103
|
+
|
104
|
+
-w, \--warn
|
105
|
+
: Turn on verbose warnings, the $VERBOSE variable is set to true.
|
106
|
+
|
107
|
+
-I, \--include PATH
|
108
|
+
: specify $LOAD_PATH. PATH will be prepended to $LOAD_PATH.
|
109
|
+
The \':\' character may be used to delimit multiple directories.
|
110
|
+
This directive may be used more than once. Modifications to
|
111
|
+
$LOAD_PATH take place immediately and in the order they were
|
112
|
+
specified on the command-line.
|
113
|
+
|
114
|
+
-r, \--require LIBRARY
|
115
|
+
: require a specified LIBRARY before executing the application. The
|
116
|
+
\"require\" statement will be executed immediately and in the order
|
117
|
+
they were specified on the command-line.
|
118
|
+
|
119
|
+
# SIGNALS
|
120
|
+
|
121
|
+
See yahns(1)
|
122
|
+
|
123
|
+
# FILES
|
124
|
+
|
125
|
+
See Rack documentation for a description of the rackup file format.
|
126
|
+
|
127
|
+
# ENVIRONMENT VARIABLES
|
128
|
+
|
129
|
+
The RACK_ENV variable is set by the aforementioned \-E switch.
|
130
|
+
If RACK_ENV is already set, it will be used unless \-E is used.
|
131
|
+
See rackup documentation for more details.
|
132
|
+
|
133
|
+
# CONTACT
|
134
|
+
|
135
|
+
All feedback welcome via plain-text mail to <yahns-public@rubyforge.org>\
|
136
|
+
No subscription is necessary to post to the mailing list.
|
137
|
+
|
138
|
+
# COPYRIGHT
|
139
|
+
|
140
|
+
Copyright 2013, Eric Wong <normalperson@yhbt.net> and all contributors.\
|
141
|
+
License: GPLv3 or later <http://www.gnu.org/licenses/gpl-3.0.txt>
|
142
|
+
|
143
|
+
# SEE ALSO
|
144
|
+
|
145
|
+
yahns(1), yahns_config(5)
|
146
|
+
|
147
|
+
* *Rack::Builder* ri/RDoc
|
148
|
+
* [Rack RDoc][1]
|
149
|
+
* [Rackup HowTo][2]
|
150
|
+
|
151
|
+
[1]: http://rack.rubyforge.org/doc/
|
152
|
+
[2]: http://wiki.github.com/rack/rack/tutorial-rackup-howto
|
@@ -0,0 +1,68 @@
|
|
1
|
+
% yahns(1) yahns user manual
|
2
|
+
%
|
3
|
+
|
4
|
+
# NAME
|
5
|
+
|
6
|
+
yahns - multi-threaded, non-blocking application server for Ruby
|
7
|
+
|
8
|
+
# SYNOPSYS
|
9
|
+
|
10
|
+
yahns -c CONFIG_FILE [-D|--daemonize]
|
11
|
+
|
12
|
+
# DESCRIPTION
|
13
|
+
|
14
|
+
yahns(1) is the primary interface for launching a yahns application
|
15
|
+
server. The configuration file is documented in yahns_config(5). yahns
|
16
|
+
hosts Rack HTTP applications, but may support others in the future such
|
17
|
+
as DRb.
|
18
|
+
|
19
|
+
# SIGNALS
|
20
|
+
|
21
|
+
The following UNIX signals may be sent to the running yahns process.
|
22
|
+
If yahns is configured for worker_processes (optional), signals should
|
23
|
+
only be sent to the master process.
|
24
|
+
|
25
|
+
* INT/TERM/QUIT - graceful shutdown. If repeated (any of these signals
|
26
|
+
is sent twice), shutdown occurs immediately.
|
27
|
+
* USR1 - reopen all logs owned by the master and all workers.
|
28
|
+
This scans the Ruby ObjectSpace for all open File objects with the O_APPEND
|
29
|
+
file flag and buffering disabled (IO#sync==false)
|
30
|
+
* USR2 - reexecute the running binary. A separate QUIT should be sent to
|
31
|
+
* HUP - if worker_processes are not used, this will reexecute the running
|
32
|
+
binary and gracefully exit the running process. If worker_processes are
|
33
|
+
used, this will reload config file, app, and gracefully restart all workers
|
34
|
+
* WINCH - gracefully stops workers but keep the master running.
|
35
|
+
This will only work for daemonized processes and only if the
|
36
|
+
worker_processes configuration directive is used.
|
37
|
+
* TTIN - increment the number of worker processes by one
|
38
|
+
(only if the worker_processes directive is used)
|
39
|
+
* TTOU - decrement the number of worker processes by one
|
40
|
+
(only if the worker_processes directive is used)
|
41
|
+
|
42
|
+
# ENVIRONMENT
|
43
|
+
|
44
|
+
yahns(1) itself requires no special environment variables. However,
|
45
|
+
environment variables such as RACK_ENV and RAILS_ENV can affect Rack and
|
46
|
+
Rails applications it hosts. Ruby and C library implementation-specific
|
47
|
+
environment variables will also affect it.
|
48
|
+
|
49
|
+
yahns will update the PWD (current working directory) env if the
|
50
|
+
working_directory directive is set (see yahns_config(5)).
|
51
|
+
|
52
|
+
# FILES
|
53
|
+
|
54
|
+
See yahns_config(5) for documentation on the configuration file format.
|
55
|
+
|
56
|
+
# CONTACT
|
57
|
+
|
58
|
+
All feedback welcome via plain-text mail to <yahns-public@rubyforge.org>\
|
59
|
+
No subscription is necessary to post to the mailing list.
|
60
|
+
|
61
|
+
# COPYRIGHT
|
62
|
+
|
63
|
+
Copyright 2013, Eric Wong <normalperson@yhbt.net> and all contributors.\
|
64
|
+
License: GPLv3 or later <http://www.gnu.org/licenses/gpl-3.0.txt>
|
65
|
+
|
66
|
+
# SEE ALSO
|
67
|
+
|
68
|
+
yahns-rackup(1), yahns_config(5)
|
@@ -0,0 +1,563 @@
|
|
1
|
+
% yahns_config(5) yahns user manual
|
2
|
+
%
|
3
|
+
|
4
|
+
# NAME
|
5
|
+
|
6
|
+
yahns_config - configuration file description for yahns(1)
|
7
|
+
|
8
|
+
# DESCRIPTION
|
9
|
+
|
10
|
+
Since yahns is a Ruby application server, its configuration file is
|
11
|
+
implemented in Ruby syntax, making it dependent on the version of
|
12
|
+
Ruby it is running under.
|
13
|
+
|
14
|
+
# TOP-LEVEL DIRECTIVES
|
15
|
+
|
16
|
+
* app :TYPE, *APP_ARGUMENTS, &BLOCK
|
17
|
+
|
18
|
+
This defines an application context for yahns to run. :TYPE defines
|
19
|
+
the type of application it runs. yahns will eventually support
|
20
|
+
application types other than :rack, but for now, only :rack is
|
21
|
+
supported.
|
22
|
+
|
23
|
+
The &BLOCK given configures the which sockets the app listens on,
|
24
|
+
buffering and logging settings.
|
25
|
+
|
26
|
+
An app with the same :TYPE and APP_ARGUMENTS may be defined multiple
|
27
|
+
times with different &BLOCK contents (with different listeners and
|
28
|
+
buffering settings).
|
29
|
+
|
30
|
+
See the APP-BLOCK DIRECTIVES section for details on what goes into
|
31
|
+
the &BLOCK.
|
32
|
+
|
33
|
+
This directive may be specified multiple times for different or
|
34
|
+
identical applications.
|
35
|
+
|
36
|
+
If the "working_directory" directive is used, all app directives may
|
37
|
+
only be specified after setting "working_directory".
|
38
|
+
|
39
|
+
For Rack HTTP applications, see RACK APP ARGUMENTS for more
|
40
|
+
information.
|
41
|
+
|
42
|
+
* before_exec &BLOCK
|
43
|
+
|
44
|
+
This runs &BLOCK before Kernel#exec (execve(2) wrapper). The command
|
45
|
+
array to be passed to Kernel#exec may be modified within this hook:
|
46
|
+
|
47
|
+
before_exec do |cmd|
|
48
|
+
# you may modify ENV here inside the child process
|
49
|
+
ENV["MALLOC_ARENA_MAX"] = ENV["MALLOC_ARENA_TEST"] = "1"
|
50
|
+
|
51
|
+
# You may change to a different installation of Ruby or yahns
|
52
|
+
# by doing an in-place modification of cmd:
|
53
|
+
cmd.replace(%W(/another/install/of/yahns -c cfg.rb))
|
54
|
+
end
|
55
|
+
|
56
|
+
Default: (none)
|
57
|
+
|
58
|
+
* client_expire_threshold {INTEGER|FLOAT}
|
59
|
+
|
60
|
+
yahns will start expiring idle clients when it hits this threshold.
|
61
|
+
If the threshold is a floating point number, it is that fraction of
|
62
|
+
the soft open file limit (RLIMIT_NOFILE ir `ulimit -S -n` in shell).
|
63
|
+
Thus if the soft open file limit is 1024 (a typical value) and the
|
64
|
+
client_expire_threshold is 0.3, yahns will start expiring clients once
|
65
|
+
it hits 307 clients (0.3 * 1024).
|
66
|
+
|
67
|
+
If given a positive integer, yahns will start expiring clients once it
|
68
|
+
its this absolute threshold of connected clients.
|
69
|
+
|
70
|
+
If given a negative integer, yahns will start expiring clients once it
|
71
|
+
reaches N clients away from the the soft file limit. That is, if
|
72
|
+
client_expire_threshold is -666 and the soft open file limit is 1024,
|
73
|
+
it will start expiring once it hits 358 clients.
|
74
|
+
|
75
|
+
Clients are expired when the configured client_timeout for their
|
76
|
+
app context is hit.
|
77
|
+
|
78
|
+
Default: 0.5
|
79
|
+
|
80
|
+
* logger LOGGER
|
81
|
+
|
82
|
+
Sets LOGGER as the default logger of the process. The new
|
83
|
+
LOGGER must respond to the following methods:
|
84
|
+
|
85
|
+
debug, info, warn, error, fatal
|
86
|
+
|
87
|
+
The default logger will log its output to the path specified
|
88
|
+
by stderr_path. If you're running yahns daemonized, then
|
89
|
+
you must specify a path to prevent error messages from going
|
90
|
+
to /dev/null
|
91
|
+
|
92
|
+
A per-APP &BLOCK logger may also be configured inside an app &BLOCK.
|
93
|
+
|
94
|
+
Default: Logger.new($stderr)
|
95
|
+
|
96
|
+
* pid PATHNAME
|
97
|
+
|
98
|
+
Sets the path of the PID file for use with management/init scripts.
|
99
|
+
|
100
|
+
Default: none
|
101
|
+
|
102
|
+
* queue [NAME] &BLOCK
|
103
|
+
|
104
|
+
As a top-level directive, this configures or defines a queue.
|
105
|
+
If no NAME is specified, a default queue (named :default) is
|
106
|
+
assumed. See the QUEUE-LEVEL DIRECTIVES section for details.
|
107
|
+
|
108
|
+
A &BLOCK must be given if used as a top-level directive. This
|
109
|
+
behaves slightly differently inside an app &BLOCK. This may also
|
110
|
+
be given without a block to associate an app block with a named
|
111
|
+
queue.
|
112
|
+
|
113
|
+
Usually, only one queue is necessary. Each queue corresponds to
|
114
|
+
an epoll descriptor and worker thread pool.
|
115
|
+
|
116
|
+
Default: NAME defaults to :default
|
117
|
+
|
118
|
+
* stderr_path PATHNAME
|
119
|
+
|
120
|
+
Allow redirecting $stderr to a given path. Unlike doing this from
|
121
|
+
the shell, this allows the yahns process to know the path its
|
122
|
+
writing to and rotate the file if it is used for logging. The
|
123
|
+
file will be opened with the O_APPEND flag and writes
|
124
|
+
synchronized to the kernel (but not necessarily to _disk_) so
|
125
|
+
multiple processes can safely append to it.
|
126
|
+
|
127
|
+
If you are daemonizing and using the default logger, it is important
|
128
|
+
to specify this as errors will otherwise be lost to /dev/null.
|
129
|
+
Some applications/libraries may also triggering warnings that go to
|
130
|
+
stderr, and they will end up here.
|
131
|
+
|
132
|
+
Default: /dev/null if daemonized, controlling terminal if not
|
133
|
+
|
134
|
+
* stdout_path PATHNAME
|
135
|
+
|
136
|
+
Same as stderr_path, except for $stdout. Not many applications
|
137
|
+
write to $stdout, but any that do will have their output written here.
|
138
|
+
It is safe to point this to the same location a stderr_path.
|
139
|
+
Like stderr_path, this defaults to /dev/null when daemonized.
|
140
|
+
|
141
|
+
Default: /dev/null if daemonized, controlling terminal if not
|
142
|
+
|
143
|
+
* working_directory PATHNAME
|
144
|
+
|
145
|
+
Sets the working directory for the process. This ensures SIGUSR2 will
|
146
|
+
start a new instance of yahns in this directory. This may be
|
147
|
+
a symlink, a common scenario for Capistrano users. Unlike
|
148
|
+
all other yahns configuration directives, this binds immediately
|
149
|
+
for error checking and cannot be undone by unsetting it in the
|
150
|
+
configuration file and reloading.
|
151
|
+
|
152
|
+
This must be specified before any "app" directives
|
153
|
+
|
154
|
+
Default: / if daemonized, current working directory if not
|
155
|
+
|
156
|
+
# QUEUE-LEVEL DIRECTIVES
|
157
|
+
|
158
|
+
* max_events INTEGER
|
159
|
+
|
160
|
+
This controls the number of events a worker thread will fetch at
|
161
|
+
once via epoll_wait(2). There is no good reason to change this
|
162
|
+
unless you use very few (e.g. 1) worker_threads. Leaving this at
|
163
|
+
1 will give the fairest load balancing behavior with epoll.
|
164
|
+
|
165
|
+
Default: 1
|
166
|
+
|
167
|
+
* worker_threads INTEGER
|
168
|
+
|
169
|
+
This controls the number of threads for application processing.
|
170
|
+
Each queue has its own thread pool. Increase this number if your
|
171
|
+
applications are able to use more threads effectively or if either
|
172
|
+
(or both) input/output buffering are disabled. Lower this number if
|
173
|
+
you do not need multi-thread concurrency at all.
|
174
|
+
|
175
|
+
Default: 7
|
176
|
+
|
177
|
+
## APP-BLOCK DIRECTIVES
|
178
|
+
|
179
|
+
* atfork_prepare, atfork_parent, atfork_child
|
180
|
+
|
181
|
+
These are identical to the methods defined in WORKER_PROCESSES-LEVEL
|
182
|
+
DIRECTIVES, however they are available inside the app blocks for
|
183
|
+
convenience in case it is easier to organize per-app hooks.
|
184
|
+
|
185
|
+
Default: (none)
|
186
|
+
|
187
|
+
* check_client_connection BOOLEAN
|
188
|
+
|
189
|
+
When enabled, yahns will check the client connection by writing
|
190
|
+
the beginning of the HTTP headers before calling the application.
|
191
|
+
|
192
|
+
This can prevent calling the application for clients who have
|
193
|
+
disconnected while their connection was waiting for a free
|
194
|
+
worker thread.
|
195
|
+
|
196
|
+
This only affects clients connecting over Unix domain sockets and
|
197
|
+
TCP via loopback (127.*.*.*). It is unlikely to detect disconnects
|
198
|
+
if the client is on a remote host (even on a fast LAN).
|
199
|
+
|
200
|
+
This has no effect for (rare) HTTP/0.9 clients.
|
201
|
+
|
202
|
+
Default: false
|
203
|
+
|
204
|
+
* client_body_buffer_size INTEGER
|
205
|
+
|
206
|
+
This controls the maximum size of a request body before it is
|
207
|
+
buffered to the filesystem (instead of memory). This has no effect
|
208
|
+
if input_buffering is false. This also governs the size of an
|
209
|
+
individual read(2) system call when reading a request body.
|
210
|
+
|
211
|
+
Default: 8192 bytes (8 kilobytes)
|
212
|
+
|
213
|
+
* client_header_buffer_size INTEGER
|
214
|
+
|
215
|
+
This controls the size of a single read(2) syscall for reading
|
216
|
+
client request headers. Increase this as needed if your application
|
217
|
+
uses large cookies or long URLs. Lowering this may reduce GC and
|
218
|
+
memory allocator overhead.
|
219
|
+
|
220
|
+
Default 4000 bytes
|
221
|
+
|
222
|
+
* client_max_body_size {INTEGER|nil}
|
223
|
+
|
224
|
+
This controls the maximum request body size before a client is
|
225
|
+
rejected with an HTTP 413 error.
|
226
|
+
|
227
|
+
Setting this to nil will allow unlimited-sized inputs.
|
228
|
+
|
229
|
+
Default: 1048576 bytes (one megabyte)
|
230
|
+
|
231
|
+
* client_timeout SECONDS
|
232
|
+
|
233
|
+
Defines the timeout expiring idle connections.
|
234
|
+
|
235
|
+
If input_buffering is false or :lazy, this defines the maximum
|
236
|
+
amount of time a worker thread will wait synchronously for a client
|
237
|
+
request body.
|
238
|
+
|
239
|
+
If output_buffering is false, this defines the maximm amount of
|
240
|
+
time a worker thread will wait synchronously for a client socket
|
241
|
+
to become writable.
|
242
|
+
|
243
|
+
It makes sense to lower this to a low value (e.g. 5 seconds) if
|
244
|
+
either output or input buffering are disabled. The default value
|
245
|
+
of 15 seconds is suitable for configurations with both input and
|
246
|
+
output buffering enabled and assumes all application dispatch
|
247
|
+
finishes in less than 15 seconds.
|
248
|
+
|
249
|
+
Default: 15 (seconds)
|
250
|
+
|
251
|
+
* errors {IO|PATHNAME}
|
252
|
+
|
253
|
+
For Rack applications, this controls the env["rack.errors"]
|
254
|
+
destination. If given a PATHNAME, it will be a writable file
|
255
|
+
opened with O_APPEND without userspace buffering, making it suitable
|
256
|
+
for concurrent appends by multiple processes and threads, as well as
|
257
|
+
making it eligible for reopening via SIGUSR1 after log rotation.
|
258
|
+
|
259
|
+
Default: $stderr
|
260
|
+
|
261
|
+
* input_buffering {:lazy|true|false}[, OPTIONS]
|
262
|
+
|
263
|
+
This controls buffering of the HTTP request body.
|
264
|
+
|
265
|
+
+ true - fully buffers the request before application dispatch. This is
|
266
|
+
most suitable for slow and untrusted clients which may trickle
|
267
|
+
the request to the server.
|
268
|
+
|
269
|
+
+ :lazy - provides streaming, but rewindable input. This is suitable
|
270
|
+
for fast, trusted clients and is fully-compatible with Rack 1.x
|
271
|
+
specifications. :lazy buffering may also be suitable for slow and
|
272
|
+
untrusted clients if you are able and willing to run a queue with
|
273
|
+
many worker threads.
|
274
|
+
|
275
|
+
+ false - disable input buffering completely. This violates the
|
276
|
+
Rack 1.x spec and is only suitable for fast, trusted clients or
|
277
|
+
queues with many worker threads.
|
278
|
+
|
279
|
+
HTTP request headers are always buffered in memory.
|
280
|
+
|
281
|
+
Default: true
|
282
|
+
|
283
|
+
The following OPTIONS may be specified:
|
284
|
+
|
285
|
+
+ tmpdir: DIRECTORY
|
286
|
+
|
287
|
+
Specify an alternative temporary directory of input_buffering is
|
288
|
+
:lazy or true. This can be used in case the normal temporary
|
289
|
+
directory is too small or busy to be used for input buffering.
|
290
|
+
|
291
|
+
Default: Dir.tmpdir (usually from TMPDIR env or /tmp)
|
292
|
+
|
293
|
+
* listen ADDRESS [, OPTIONS]
|
294
|
+
|
295
|
+
Adds an ADDRESS to the existing listener set. May be specified more
|
296
|
+
than once. ADDRESS may be an Integer port number for a TCP port, an
|
297
|
+
"IP_ADDRESS:PORT" for TCP listeners or a pathname for UNIX domain sockets.
|
298
|
+
|
299
|
+
listen 3000 # listen to port 3000 on all TCP interfaces
|
300
|
+
listen "127.0.0.1:3000" # listen to port 3000 on the loopback interface
|
301
|
+
listen "/path/to/.unicorn.sock" # listen on the given Unix domain socket
|
302
|
+
listen "[::1]:3000" # listen to port 3000 on the IPv6 loopback interface
|
303
|
+
|
304
|
+
When using Unix domain sockets, be sure:
|
305
|
+
1) the path matches the one used by nginx
|
306
|
+
2) uses the same filesystem namespace as the nginx process
|
307
|
+
For systemd users using PrivateTmp=true (for either nginx or yahns),
|
308
|
+
this means Unix domain sockets must not be placed in /tmp
|
309
|
+
|
310
|
+
The following OPTIONS may be specified (but are generally not needed):
|
311
|
+
|
312
|
+
+ backlog: INTEGER
|
313
|
+
|
314
|
+
This is the backlog of the listen(2) syscall.
|
315
|
+
|
316
|
+
Some operating systems allow negative values here to specify the
|
317
|
+
maximum allowable value. In most cases, this number is only
|
318
|
+
recommendation and there are other OS-specific tunables and
|
319
|
+
variables that can affect this number. See the listen(2)
|
320
|
+
syscall documentation of your OS for the exact semantics of
|
321
|
+
this.
|
322
|
+
|
323
|
+
If you are running unicorn on multiple machines, lowering this number
|
324
|
+
can help your load balancer detect when a machine is overloaded
|
325
|
+
and give requests to a different machine.
|
326
|
+
|
327
|
+
Default: 1024
|
328
|
+
|
329
|
+
+ ipv6only: BOOLEAN
|
330
|
+
|
331
|
+
This option makes IPv6-capable TCP listeners IPv6-only and unable
|
332
|
+
to receive IPv4 queries on dual-stack systems. A separate IPv4-only
|
333
|
+
listener is required if this is true.
|
334
|
+
|
335
|
+
Enabling this option for the IPv6-only listener and having a
|
336
|
+
separate IPv4 listener is recommended if you wish to support IPv6
|
337
|
+
on the same TCP port. Otherwise, the value of env["REMOTE_ADDR"]
|
338
|
+
will appear as an ugly IPv4-mapped-IPv6 address for IPv4 clients
|
339
|
+
(e.g ":ffff:10.0.0.1" instead of just "10.0.0.1").
|
340
|
+
|
341
|
+
Default: Operating-system dependent
|
342
|
+
|
343
|
+
+ sndbuf / rcvbuf: INTEGER
|
344
|
+
|
345
|
+
Maximum receive and send buffer sizes (in bytes) of sockets.
|
346
|
+
|
347
|
+
These correspond to the SO_RCVBUF and SO_SNDBUF settings which
|
348
|
+
can be set via the setsockopt(2) syscall. Some kernels
|
349
|
+
(e.g. Linux 2.4+) have intelligent auto-tuning mechanisms and
|
350
|
+
there is no need (and it is sometimes detrimental) to specify them.
|
351
|
+
|
352
|
+
See the socket API documentation of your operating system
|
353
|
+
to determine the exact semantics of these settings and
|
354
|
+
other operating system-specific knobs where they can be
|
355
|
+
specified.
|
356
|
+
|
357
|
+
Defaults: operating system defaults
|
358
|
+
|
359
|
+
+ reuseport: BOOLEAN
|
360
|
+
|
361
|
+
This enables multiple, independently-started yahns instances to
|
362
|
+
bind to the same port (as long as all the processes enable this).
|
363
|
+
|
364
|
+
This option must be used when yahns first binds the listen socket.
|
365
|
+
It cannot be enabled when a socket is inherited via SIGUSR2
|
366
|
+
(but it will remain on if inherited), and it cannot be enabled
|
367
|
+
directly via SIGHUP.
|
368
|
+
|
369
|
+
Note: there is a chance of connections being dropped if
|
370
|
+
one of the yahns instances is stopped while using this.
|
371
|
+
|
372
|
+
This is supported on *BSD systems and Linux 3.9 or later.
|
373
|
+
|
374
|
+
ref: https://lwn.net/Articles/542629/
|
375
|
+
|
376
|
+
Default: false (unset)
|
377
|
+
|
378
|
+
+ threads: INTEGER
|
379
|
+
|
380
|
+
Used to control the number of threads blocking on the accept(2)
|
381
|
+
or accept4(2) system call (per listen socket).
|
382
|
+
|
383
|
+
Usually, only one thread here is necessary, especially when
|
384
|
+
multiple worker_processes are configured (as there'll be one
|
385
|
+
thread per-process). Having extra threads may increase
|
386
|
+
contention with epoll and FD allocation within one process.
|
387
|
+
|
388
|
+
Note: do not confuse this option with worker_threads for queues,
|
389
|
+
each queue has their own thread pool and it makes sense to
|
390
|
+
have multiple threads there.
|
391
|
+
|
392
|
+
Default: 1
|
393
|
+
|
394
|
+
+ umask: MODE
|
395
|
+
|
396
|
+
Sets the file mode creation mask for UNIX sockets. If specified,
|
397
|
+
this is usually in octal notation.
|
398
|
+
|
399
|
+
Typically UNIX domain sockets are created with more liberal
|
400
|
+
file permissions than the rest of the application. By default,
|
401
|
+
we create UNIX domain sockets to be readable and writable by
|
402
|
+
all local users to give them the same accessibility as
|
403
|
+
locally-bound TCP listeners.
|
404
|
+
|
405
|
+
This has no effect on TCP listeners.
|
406
|
+
|
407
|
+
Default: 0000 (world-read/writable)
|
408
|
+
|
409
|
+
* logger LOGGER
|
410
|
+
|
411
|
+
Configures a logger within the current app &BLOCK.
|
412
|
+
This behaves the same as the logger directive described in
|
413
|
+
TOP-LEVEL DIRECTIVES
|
414
|
+
|
415
|
+
Default: uses the top-level logger
|
416
|
+
|
417
|
+
* output_buffering BOOLEAN [, OPTIONS]
|
418
|
+
|
419
|
+
This enables or disables buffering of the HTTP response. If enabled,
|
420
|
+
buffering is only performed lazily. In other words, buffering only
|
421
|
+
happens if socket buffers (in the kernel) are filled up.
|
422
|
+
|
423
|
+
Disabling output buffering is only recommended if all clients
|
424
|
+
connecting to this application context are fast, trusted or
|
425
|
+
you are willing and able to run many worker threads.
|
426
|
+
|
427
|
+
If output buffering is disabled, client_timeout controls the maximum
|
428
|
+
amount of time a worker thread will wait synchronously.
|
429
|
+
|
430
|
+
Default: true
|
431
|
+
|
432
|
+
The following OPTIONS may be specified:
|
433
|
+
|
434
|
+
+ tmpdir: DIRECTORY
|
435
|
+
|
436
|
+
Specify an alternative temporary directory of output_buffering is
|
437
|
+
enabled. This can be used in case the normal temporary directory
|
438
|
+
is too small or busy to be used for output buffering.
|
439
|
+
|
440
|
+
Default: Dir.tmpdir (usually from TMPDIR env or /tmp)
|
441
|
+
|
442
|
+
* persistent_connections BOOLEAN
|
443
|
+
|
444
|
+
Enable or disables persistent connections and pipelining for HTTP
|
445
|
+
connections. Persistent connections only expire when the global
|
446
|
+
client_expire_threshold is hit and a client hits its client_timeout.
|
447
|
+
|
448
|
+
Default: true
|
449
|
+
|
450
|
+
* user USER [,GROUP]
|
451
|
+
|
452
|
+
Runs application process(es) as the specified USER and GROUP.
|
453
|
+
|
454
|
+
If using worker_processes, this only affects the workers and the
|
455
|
+
master stays running as the user who started it. This switch will
|
456
|
+
occur before calling the atfork_child hook(s).
|
457
|
+
|
458
|
+
GROUP is optional and will not change if unspecified.
|
459
|
+
|
460
|
+
Default: none (no user switching is done)
|
461
|
+
|
462
|
+
* queue [NAME or &BLOCK]
|
463
|
+
|
464
|
+
If given a NAME-only, this will associate this app &BLOCK with an
|
465
|
+
existing queue.
|
466
|
+
|
467
|
+
If given a &BLOCK-only, this will create an anonymous queue for this
|
468
|
+
application context only. If given a &BLOCK, this takes the same
|
469
|
+
parameters (worker_threads and max_events) as described in
|
470
|
+
QUEUE-LEVEL DIRECTIVES.
|
471
|
+
|
472
|
+
NAME and &BLOCK may not be combined inside an app &BLOCK.
|
473
|
+
|
474
|
+
Default: uses the global, :default queue if none is specified
|
475
|
+
|
476
|
+
* shutdown_timeout SECONDS
|
477
|
+
|
478
|
+
This defines the timeout for gracefully exiting the process if there
|
479
|
+
are still connected clients. This should generally be higher or equal
|
480
|
+
to the app with the highest client_timeout value.
|
481
|
+
|
482
|
+
Increase this if your application has slow endpoints which may take
|
483
|
+
longer than the default timeout.
|
484
|
+
|
485
|
+
Default: max client_timeout value of all apps in the process
|
486
|
+
|
487
|
+
* worker_processes INTEGER [&BLOCK]
|
488
|
+
|
489
|
+
This directive allows yahns to use a master/worker configuration to
|
490
|
+
use multiple processes. Specifying any numeric value (including 1)
|
491
|
+
here means yahns will enable yahns to use a master/worker process
|
492
|
+
model instead of a single process.
|
493
|
+
|
494
|
+
If an optional &BLOCK is given, it may be used to configure
|
495
|
+
pthread_atfork(3)-style hooks. See WORKER_PROCESSES-LEVEL DIRECTIVES
|
496
|
+
for details.
|
497
|
+
|
498
|
+
Default: nil (single process, no master/worker separation)
|
499
|
+
|
500
|
+
## WORKER_PROCESSES-LEVEL DIRECTIVES
|
501
|
+
|
502
|
+
Note: all of the atfork_* hooks described here are available inside the
|
503
|
+
"app" blocks, too.
|
504
|
+
|
505
|
+
* atfork_prepare &BLOCK
|
506
|
+
|
507
|
+
This &BLOCK is executed in the parent before fork(2) operation.
|
508
|
+
This may be useful for app directives which specify "preload: true"
|
509
|
+
to disconnect from databases or otherwise close open file descriptors
|
510
|
+
to prevent them from being shared with the children.
|
511
|
+
|
512
|
+
Default: none
|
513
|
+
|
514
|
+
* atfork_parent &BLOCK
|
515
|
+
|
516
|
+
This &BLOCK is executed in the parent after the fork(2) operation.
|
517
|
+
This may not be useful, but exists in case somebody finds a use for it.
|
518
|
+
|
519
|
+
Default: none
|
520
|
+
|
521
|
+
* atfork_child &BLOCK
|
522
|
+
|
523
|
+
This &BLOCK is executed in the child after the fork(2) operation.
|
524
|
+
|
525
|
+
This may be useful for app directives which specify "preload: true"
|
526
|
+
to reconnect to databases or reopen closed file descriptors which
|
527
|
+
were closed in the atfork_prepare hook.
|
528
|
+
|
529
|
+
Default: none
|
530
|
+
|
531
|
+
# RACK APP ARGUMENTS
|
532
|
+
|
533
|
+
Rack applications take a PATHNAME to the rackup(1) config file (e.g.
|
534
|
+
"config.ru") as its first argument.
|
535
|
+
|
536
|
+
The only supported keyword argument is the preload: BOOLEAN.
|
537
|
+
|
538
|
+
preload: only makes sense if worker_processes are configured.
|
539
|
+
Preloading an app allows memory to be saved under a copy-on-write GC,
|
540
|
+
but will often require atfork_* hooks to be registered when configuring
|
541
|
+
worker_processes. preload: defaults to false for maximum out-of-the-box
|
542
|
+
compatibility.
|
543
|
+
|
544
|
+
## RACK APP EXAMPLE
|
545
|
+
|
546
|
+
app(:rack, "/path/to/config.ru", preload: false) do
|
547
|
+
# APP-BLOCK DIRECTIVES GO HERE
|
548
|
+
end
|
549
|
+
|
550
|
+
# EXAMPLES
|
551
|
+
|
552
|
+
See the examples/ directory in the git source tree.
|
553
|
+
|
554
|
+
git clone git://yhbt.net/yahns.git
|
555
|
+
|
556
|
+
# COPYRIGHT
|
557
|
+
|
558
|
+
Copyright 2013, Eric Wong <normalperson@yhbt.net> and all contributors.\
|
559
|
+
License: GPLv3 or later <http://www.gnu.org/licenses/gpl-3.0.txt>
|
560
|
+
|
561
|
+
# SEE ALSO
|
562
|
+
|
563
|
+
yahns(1)
|