unicorn-simon 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +7 -0
  2. data/.CHANGELOG.old +25 -0
  3. data/.document +28 -0
  4. data/.gitattributes +5 -0
  5. data/.gitignore +25 -0
  6. data/.mailmap +26 -0
  7. data/.manifest +156 -0
  8. data/.olddoc.yml +18 -0
  9. data/Application_Timeouts +77 -0
  10. data/CONTRIBUTORS +35 -0
  11. data/COPYING +674 -0
  12. data/DESIGN +95 -0
  13. data/Documentation/.gitignore +5 -0
  14. data/Documentation/GNUmakefile +30 -0
  15. data/Documentation/unicorn.1.txt +187 -0
  16. data/Documentation/unicorn_rails.1.txt +175 -0
  17. data/FAQ +70 -0
  18. data/GIT-VERSION-FILE +1 -0
  19. data/GIT-VERSION-GEN +39 -0
  20. data/GNUmakefile +253 -0
  21. data/HACKING +120 -0
  22. data/ISSUES +90 -0
  23. data/KNOWN_ISSUES +79 -0
  24. data/LATEST +30 -0
  25. data/LICENSE +67 -0
  26. data/Links +56 -0
  27. data/NEWS +2465 -0
  28. data/PHILOSOPHY +139 -0
  29. data/README +138 -0
  30. data/Rakefile +16 -0
  31. data/SIGNALS +123 -0
  32. data/Sandbox +104 -0
  33. data/TODO +3 -0
  34. data/TUNING +119 -0
  35. data/archive/.gitignore +3 -0
  36. data/archive/slrnpull.conf +4 -0
  37. data/bin/unicorn +126 -0
  38. data/bin/unicorn_rails +209 -0
  39. data/examples/big_app_gc.rb +2 -0
  40. data/examples/echo.ru +27 -0
  41. data/examples/init.sh +102 -0
  42. data/examples/logger_mp_safe.rb +25 -0
  43. data/examples/logrotate.conf +44 -0
  44. data/examples/nginx.conf +155 -0
  45. data/examples/unicorn.conf.minimal.rb +13 -0
  46. data/examples/unicorn.conf.rb +110 -0
  47. data/examples/unicorn.socket +11 -0
  48. data/examples/unicorn@.service +33 -0
  49. data/ext/unicorn_http/CFLAGS +13 -0
  50. data/ext/unicorn_http/c_util.h +124 -0
  51. data/ext/unicorn_http/common_field_optimization.h +111 -0
  52. data/ext/unicorn_http/ext_help.h +62 -0
  53. data/ext/unicorn_http/extconf.rb +11 -0
  54. data/ext/unicorn_http/global_variables.h +97 -0
  55. data/ext/unicorn_http/httpdate.c +78 -0
  56. data/ext/unicorn_http/unicorn_http.c +4274 -0
  57. data/ext/unicorn_http/unicorn_http.rl +980 -0
  58. data/ext/unicorn_http/unicorn_http_common.rl +76 -0
  59. data/lib/unicorn/app/old_rails/static.rb +59 -0
  60. data/lib/unicorn/app/old_rails.rb +35 -0
  61. data/lib/unicorn/cgi_wrapper.rb +147 -0
  62. data/lib/unicorn/configurator.rb +664 -0
  63. data/lib/unicorn/const.rb +21 -0
  64. data/lib/unicorn/http_request.rb +122 -0
  65. data/lib/unicorn/http_response.rb +60 -0
  66. data/lib/unicorn/http_server.rb +824 -0
  67. data/lib/unicorn/launcher.rb +62 -0
  68. data/lib/unicorn/oob_gc.rb +82 -0
  69. data/lib/unicorn/preread_input.rb +33 -0
  70. data/lib/unicorn/socket_helper.rb +195 -0
  71. data/lib/unicorn/stream_input.rb +146 -0
  72. data/lib/unicorn/tee_input.rb +133 -0
  73. data/lib/unicorn/tmpio.rb +27 -0
  74. data/lib/unicorn/util.rb +90 -0
  75. data/lib/unicorn/version.rb +1 -0
  76. data/lib/unicorn/worker.rb +140 -0
  77. data/lib/unicorn.rb +123 -0
  78. data/man/man1/unicorn.1 +221 -0
  79. data/man/man1/unicorn_rails.1 +212 -0
  80. data/setup.rb +1586 -0
  81. data/t/.gitignore +4 -0
  82. data/t/GNUmakefile +74 -0
  83. data/t/README +42 -0
  84. data/t/bin/content-md5-put +36 -0
  85. data/t/bin/sha1sum.rb +17 -0
  86. data/t/bin/unused_listen +40 -0
  87. data/t/broken-app.ru +12 -0
  88. data/t/detach.ru +11 -0
  89. data/t/env.ru +3 -0
  90. data/t/fails-rack-lint.ru +5 -0
  91. data/t/heartbeat-timeout.ru +12 -0
  92. data/t/hijack.ru +43 -0
  93. data/t/listener_names.ru +4 -0
  94. data/t/my-tap-lib.sh +201 -0
  95. data/t/oob_gc.ru +20 -0
  96. data/t/oob_gc_path.ru +20 -0
  97. data/t/pid.ru +3 -0
  98. data/t/preread_input.ru +17 -0
  99. data/t/rack-input-tests.ru +21 -0
  100. data/t/t0000-http-basic.sh +50 -0
  101. data/t/t0001-reload-bad-config.sh +53 -0
  102. data/t/t0002-config-conflict.sh +49 -0
  103. data/t/t0002-parser-error.sh +94 -0
  104. data/t/t0003-working_directory.sh +51 -0
  105. data/t/t0004-heartbeat-timeout.sh +69 -0
  106. data/t/t0004-working_directory_broken.sh +24 -0
  107. data/t/t0005-working_directory_app.rb.sh +40 -0
  108. data/t/t0006-reopen-logs.sh +83 -0
  109. data/t/t0006.ru +13 -0
  110. data/t/t0007-working_directory_no_embed_cli.sh +44 -0
  111. data/t/t0008-back_out_of_upgrade.sh +110 -0
  112. data/t/t0009-broken-app.sh +56 -0
  113. data/t/t0009-winch_ttin.sh +59 -0
  114. data/t/t0010-reap-logging.sh +55 -0
  115. data/t/t0011-active-unix-socket.sh +79 -0
  116. data/t/t0012-reload-empty-config.sh +85 -0
  117. data/t/t0013-rewindable-input-false.sh +24 -0
  118. data/t/t0013.ru +12 -0
  119. data/t/t0014-rewindable-input-true.sh +24 -0
  120. data/t/t0014.ru +12 -0
  121. data/t/t0015-configurator-internals.sh +25 -0
  122. data/t/t0018-write-on-close.sh +23 -0
  123. data/t/t0019-max_header_len.sh +49 -0
  124. data/t/t0020-at_exit-handler.sh +49 -0
  125. data/t/t0021-process_detach.sh +29 -0
  126. data/t/t0022-listener_names-preload_app.sh +32 -0
  127. data/t/t0100-rack-input-tests.sh +124 -0
  128. data/t/t0116-client_body_buffer_size.sh +80 -0
  129. data/t/t0116.ru +16 -0
  130. data/t/t0200-rack-hijack.sh +30 -0
  131. data/t/t0300-no-default-middleware.sh +20 -0
  132. data/t/t9000-preread-input.sh +48 -0
  133. data/t/t9001-oob_gc.sh +47 -0
  134. data/t/t9002-oob_gc-path.sh +75 -0
  135. data/t/test-lib.sh +128 -0
  136. data/t/write-on-close.ru +11 -0
  137. data/test/aggregate.rb +15 -0
  138. data/test/benchmark/README +50 -0
  139. data/test/benchmark/dd.ru +18 -0
  140. data/test/benchmark/stack.ru +8 -0
  141. data/test/exec/README +5 -0
  142. data/test/exec/test_exec.rb +1099 -0
  143. data/test/test_helper.rb +298 -0
  144. data/test/unit/test_configurator.rb +175 -0
  145. data/test/unit/test_droplet.rb +28 -0
  146. data/test/unit/test_http_parser.rb +886 -0
  147. data/test/unit/test_http_parser_ng.rb +633 -0
  148. data/test/unit/test_request.rb +182 -0
  149. data/test/unit/test_response.rb +111 -0
  150. data/test/unit/test_server.rb +268 -0
  151. data/test/unit/test_signals.rb +188 -0
  152. data/test/unit/test_socket_helper.rb +197 -0
  153. data/test/unit/test_stream_input.rb +203 -0
  154. data/test/unit/test_tee_input.rb +304 -0
  155. data/test/unit/test_upload.rb +306 -0
  156. data/test/unit/test_util.rb +105 -0
  157. data/unicorn.gemspec +50 -0
  158. metadata +310 -0
@@ -0,0 +1,90 @@
1
+ # -*- encoding: binary -*-
2
+
3
+ require 'fcntl'
4
+ module Unicorn::Util # :nodoc:
5
+
6
+ # :stopdoc:
7
+ def self.is_log?(fp)
8
+ append_flags = File::WRONLY | File::APPEND
9
+
10
+ ! fp.closed? &&
11
+ fp.stat.file? &&
12
+ fp.sync &&
13
+ (fp.fcntl(Fcntl::F_GETFL) & append_flags) == append_flags
14
+ rescue IOError, Errno::EBADF
15
+ false
16
+ end
17
+
18
+ def self.chown_logs(uid, gid)
19
+ ObjectSpace.each_object(File) do |fp|
20
+ fp.chown(uid, gid) if is_log?(fp)
21
+ end
22
+ end
23
+ # :startdoc:
24
+
25
+ # This reopens ALL logfiles in the process that have been rotated
26
+ # using logrotate(8) (without copytruncate) or similar tools.
27
+ # A +File+ object is considered for reopening if it is:
28
+ # 1) opened with the O_APPEND and O_WRONLY flags
29
+ # 2) the current open file handle does not match its original open path
30
+ # 3) unbuffered (as far as userspace buffering goes, not O_SYNC)
31
+ # Returns the number of files reopened
32
+ #
33
+ # In Unicorn 3.5.x and earlier, files must be opened with an absolute
34
+ # path to be considered a log file.
35
+ def self.reopen_logs
36
+ to_reopen = []
37
+ nr = 0
38
+ ObjectSpace.each_object(File) { |fp| is_log?(fp) and to_reopen << fp }
39
+
40
+ to_reopen.each do |fp|
41
+ orig_st = begin
42
+ fp.stat
43
+ rescue IOError, Errno::EBADF # race
44
+ next
45
+ end
46
+
47
+ begin
48
+ b = File.stat(fp.path)
49
+ next if orig_st.ino == b.ino && orig_st.dev == b.dev
50
+ rescue Errno::ENOENT
51
+ end
52
+
53
+ begin
54
+ # stdin, stdout, stderr are special. The following dance should
55
+ # guarantee there is no window where `fp' is unwritable in MRI
56
+ # (or any correct Ruby implementation).
57
+ #
58
+ # Fwiw, GVL has zero bearing here. This is tricky because of
59
+ # the unavoidable existence of stdio FILE * pointers for
60
+ # std{in,out,err} in all programs which may use the standard C library
61
+ if fp.fileno <= 2
62
+ # We do not want to hit fclose(3)->dup(2) window for std{in,out,err}
63
+ # MRI will use freopen(3) here internally on std{in,out,err}
64
+ fp.reopen(fp.path, "a")
65
+ else
66
+ # We should not need this workaround, Ruby can be fixed:
67
+ # http://bugs.ruby-lang.org/issues/9036
68
+ # MRI will not call call fclose(3) or freopen(3) here
69
+ # since there's no associated std{in,out,err} FILE * pointer
70
+ # This should atomically use dup3(2) (or dup2(2)) syscall
71
+ File.open(fp.path, "a") { |tmpfp| fp.reopen(tmpfp) }
72
+ end
73
+
74
+ fp.sync = true
75
+ fp.flush # IO#sync=true may not implicitly flush
76
+ new_st = fp.stat
77
+
78
+ # this should only happen in the master:
79
+ if orig_st.uid != new_st.uid || orig_st.gid != new_st.gid
80
+ fp.chown(orig_st.uid, orig_st.gid)
81
+ end
82
+
83
+ nr += 1
84
+ rescue IOError, Errno::EBADF
85
+ # not much we can do...
86
+ end
87
+ end
88
+ nr
89
+ end
90
+ end
@@ -0,0 +1 @@
1
+ Unicorn::Const::UNICORN_VERSION = '5.2.0.2.gd893.dirty'
@@ -0,0 +1,140 @@
1
+ # -*- encoding: binary -*-
2
+ require "raindrops"
3
+
4
+ # This class and its members can be considered a stable interface
5
+ # and will not change in a backwards-incompatible fashion between
6
+ # releases of unicorn. Knowledge of this class is generally not
7
+ # not needed for most users of unicorn.
8
+ #
9
+ # Some users may want to access it in the before_fork/after_fork hooks.
10
+ # See the Unicorn::Configurator RDoc for examples.
11
+ class Unicorn::Worker
12
+ # :stopdoc:
13
+ attr_accessor :nr, :switched
14
+ attr_reader :to_io # IO.select-compatible
15
+
16
+ PER_DROP = Raindrops::PAGE_SIZE / Raindrops::SIZE
17
+ DROPS = []
18
+
19
+ def initialize(nr)
20
+ drop_index = nr / PER_DROP
21
+ @raindrop = DROPS[drop_index] ||= Raindrops.new(PER_DROP)
22
+ @offset = nr % PER_DROP
23
+ @raindrop[@offset] = 0
24
+ @nr = nr
25
+ @switched = false
26
+ @to_io, @master = Unicorn.pipe
27
+ end
28
+
29
+ def atfork_child # :nodoc:
30
+ # we _must_ close in child, parent just holds this open to signal
31
+ @master = @master.close
32
+ end
33
+
34
+ # master fakes SIGQUIT using this
35
+ def quit # :nodoc:
36
+ @master = @master.close if @master
37
+ end
38
+
39
+ # parent does not read
40
+ def atfork_parent # :nodoc:
41
+ @to_io = @to_io.close
42
+ end
43
+
44
+ # call a signal handler immediately without triggering EINTR
45
+ # We do not use the more obvious Process.kill(sig, $$) here since
46
+ # that signal delivery may be deferred. We want to avoid signal delivery
47
+ # while the Rack app.call is running because some database drivers
48
+ # (e.g. ruby-pg) may cancel pending requests.
49
+ def fake_sig(sig) # :nodoc:
50
+ old_cb = trap(sig, "IGNORE")
51
+ old_cb.call
52
+ ensure
53
+ trap(sig, old_cb)
54
+ end
55
+
56
+ # master sends fake signals to children
57
+ def soft_kill(sig) # :nodoc:
58
+ case sig
59
+ when Integer
60
+ signum = sig
61
+ else
62
+ signum = Signal.list[sig.to_s] or
63
+ raise ArgumentError, "BUG: bad signal: #{sig.inspect}"
64
+ end
65
+ # writing and reading 4 bytes on a pipe is atomic on all POSIX platforms
66
+ # Do not care in the odd case the buffer is full, here.
67
+ @master.kgio_trywrite([signum].pack('l'))
68
+ rescue Errno::EPIPE
69
+ # worker will be reaped soon
70
+ end
71
+
72
+ # this only runs when the Rack app.call is not running
73
+ # act like a listener
74
+ def kgio_tryaccept # :nodoc:
75
+ case buf = @to_io.kgio_tryread(4)
76
+ when String
77
+ # unpack the buffer and trigger the signal handler
78
+ signum = buf.unpack('l')
79
+ fake_sig(signum[0])
80
+ # keep looping, more signals may be queued
81
+ when nil # EOF: master died, but we are at a safe place to exit
82
+ fake_sig(:QUIT)
83
+ when :wait_readable # keep waiting
84
+ return false
85
+ end while true # loop, as multiple signals may be sent
86
+ end
87
+
88
+ # worker objects may be compared to just plain Integers
89
+ def ==(other_nr) # :nodoc:
90
+ @nr == other_nr
91
+ end
92
+
93
+ # called in the worker process
94
+ def tick=(value) # :nodoc:
95
+ @raindrop[@offset] = value
96
+ end
97
+
98
+ # called in the master process
99
+ def tick # :nodoc:
100
+ @raindrop[@offset]
101
+ end
102
+
103
+ # called in both the master (reaping worker) and worker (SIGQUIT handler)
104
+ def close # :nodoc:
105
+ @master.close if @master
106
+ @to_io.close if @to_io
107
+ end
108
+
109
+ # :startdoc:
110
+
111
+ # In most cases, you should be using the Unicorn::Configurator#user
112
+ # directive instead. This method should only be used if you need
113
+ # fine-grained control of exactly when you want to change permissions
114
+ # in your after_fork hooks.
115
+ #
116
+ # Changes the worker process to the specified +user+ and +group+
117
+ # This is only intended to be called from within the worker
118
+ # process from the +after_fork+ hook. This should be called in
119
+ # the +after_fork+ hook after any privileged functions need to be
120
+ # run (e.g. to set per-worker CPU affinity, niceness, etc)
121
+ #
122
+ # Any and all errors raised within this method will be propagated
123
+ # directly back to the caller (usually the +after_fork+ hook.
124
+ # These errors commonly include ArgumentError for specifying an
125
+ # invalid user/group and Errno::EPERM for insufficient privileges
126
+ def user(user, group = nil)
127
+ # we do not protect the caller, checking Process.euid == 0 is
128
+ # insufficient because modern systems have fine-grained
129
+ # capabilities. Let the caller handle any and all errors.
130
+ uid = Etc.getpwnam(user).uid
131
+ gid = Etc.getgrnam(group).gid if group
132
+ Unicorn::Util.chown_logs(uid, gid)
133
+ if gid && Process.egid != gid
134
+ Process.initgroups(user, gid)
135
+ Process::GID.change_privilege(gid)
136
+ end
137
+ Process.euid != uid and Process::UID.change_privilege(uid)
138
+ @switched = true
139
+ end
140
+ end
data/lib/unicorn.rb ADDED
@@ -0,0 +1,123 @@
1
+ # -*- encoding: binary -*-
2
+ require 'etc'
3
+ require 'stringio'
4
+ require 'kgio'
5
+
6
+ begin
7
+ require 'rack'
8
+ rescue LoadError
9
+ warn 'rack not available, functionality reduced'
10
+ end
11
+
12
+ # :stopdoc:
13
+ # Unicorn module containing all of the classes (include C extensions) for
14
+ # running a Unicorn web server. It contains a minimalist HTTP server with just
15
+ # enough functionality to service web application requests fast as possible.
16
+ # :startdoc:
17
+
18
+ # unicorn exposes very little of an user-visible API and most of its
19
+ # internals are subject to change. unicorn is designed to host Rack
20
+ # applications, so applications should be written against the Rack SPEC
21
+ # and not unicorn internals.
22
+ module Unicorn
23
+
24
+ # Raised inside TeeInput when a client closes the socket inside the
25
+ # application dispatch. This is always raised with an empty backtrace
26
+ # since there is nothing in the application stack that is responsible
27
+ # for client shutdowns/disconnects. This exception is visible to Rack
28
+ # applications unless PrereadInput middleware is loaded. This
29
+ # is a subclass of the standard EOFError class and applications should
30
+ # not rescue it explicitly, but rescue EOFError instead.
31
+ ClientShutdown = Class.new(EOFError)
32
+
33
+ # :stopdoc:
34
+
35
+ # This returns a lambda to pass in as the app, this does not "build" the
36
+ # app (which we defer based on the outcome of "preload_app" in the
37
+ # Unicorn config). The returned lambda will be called when it is
38
+ # time to build the app.
39
+ def self.builder(ru, op)
40
+ # allow Configurator to parse cli switches embedded in the ru file
41
+ op = Unicorn::Configurator::RACKUP.merge!(:file => ru, :optparse => op)
42
+ if ru =~ /\.ru$/ && !defined?(Rack::Builder)
43
+ abort "rack and Rack::Builder must be available for processing #{ru}"
44
+ end
45
+
46
+ # Op is going to get cleared before the returned lambda is called, so
47
+ # save this value so that it's still there when we need it:
48
+ no_default_middleware = op[:no_default_middleware]
49
+
50
+ # always called after config file parsing, may be called after forking
51
+ lambda do ||
52
+ inner_app = case ru
53
+ when /\.ru$/
54
+ raw = File.read(ru)
55
+ raw.sub!(/^__END__\n.*/, '')
56
+ eval("Rack::Builder.new {(\n#{raw}\n)}.to_app", TOPLEVEL_BINDING, ru)
57
+ else
58
+ require ru
59
+ Object.const_get(File.basename(ru, '.rb').capitalize)
60
+ end
61
+
62
+ pp({ :inner_app => inner_app }) if $DEBUG
63
+
64
+ return inner_app if no_default_middleware
65
+
66
+ middleware = { # order matters
67
+ ContentLength: nil,
68
+ Chunked: nil,
69
+ CommonLogger: [ $stderr ],
70
+ ShowExceptions: nil,
71
+ Lint: nil,
72
+ TempfileReaper: nil,
73
+ }
74
+
75
+ # return value, matches rackup defaults based on env
76
+ # Unicorn does not support persistent connections, but Rainbows!
77
+ # and Zbatery both do. Users accustomed to the Rack::Server default
78
+ # middlewares will need ContentLength/Chunked middlewares.
79
+ case ENV["RACK_ENV"]
80
+ when "development"
81
+ when "deployment"
82
+ middleware.delete(:ShowExceptions)
83
+ middleware.delete(:Lint)
84
+ else
85
+ return inner_app
86
+ end
87
+ Rack::Builder.new do
88
+ middleware.each do |m, args|
89
+ use(Rack.const_get(m), *args) if Rack.const_defined?(m)
90
+ end
91
+ run inner_app
92
+ end.to_app
93
+ end
94
+ end
95
+
96
+ # returns an array of strings representing TCP listen socket addresses
97
+ # and Unix domain socket paths. This is useful for use with
98
+ # Raindrops::Middleware under Linux: http://raindrops.bogomips.org/
99
+ def self.listener_names
100
+ Unicorn::HttpServer::LISTENERS.map do |io|
101
+ Unicorn::SocketHelper.sock_name(io)
102
+ end + Unicorn::HttpServer::NEW_LISTENERS
103
+ end
104
+
105
+ def self.log_error(logger, prefix, exc)
106
+ message = exc.message
107
+ message = message.dump if /[[:cntrl:]]/ =~ message
108
+ logger.error "#{prefix}: #{message} (#{exc.class})"
109
+ exc.backtrace.each { |line| logger.error(line) }
110
+ end
111
+
112
+ # remove this when we only support Ruby >= 2.0
113
+ def self.pipe # :nodoc:
114
+ Kgio::Pipe.new.each { |io| io.close_on_exec = true }
115
+ end
116
+ # :startdoc:
117
+ end
118
+ # :enddoc:
119
+
120
+ %w(const socket_helper stream_input tee_input http_request configurator
121
+ tmpio util http_response worker http_server).each do |s|
122
+ require_relative "unicorn/#{s}"
123
+ end
@@ -0,0 +1,221 @@
1
+ .\" Automatically generated by Pandoc 1.19.2.1
2
+ .\"
3
+ .TH "UNICORN" "1" "September 15, 2009" "Unicorn User Manual" ""
4
+ .hy
5
+ .SH NAME
6
+ .PP
7
+ unicorn \- a rackup\-like command to launch the Unicorn HTTP server
8
+ .SH SYNOPSIS
9
+ .PP
10
+ unicorn [\-c CONFIG_FILE] [\-E RACK_ENV] [\-D] [RACKUP_FILE]
11
+ .SH DESCRIPTION
12
+ .PP
13
+ A rackup(1)\-like command to launch Rack applications using Unicorn.
14
+ It is expected to be started in your application root (APP_ROOT), but
15
+ the "working_directory" directive may be used in the CONFIG_FILE.
16
+ .PP
17
+ While unicorn takes a myriad of command\-line options for compatibility
18
+ with ruby(1) and rackup(1), it is recommended to stick to the few
19
+ command\-line options specified in the SYNOPSIS and use the CONFIG_FILE
20
+ as much as possible.
21
+ .SH RACKUP FILE
22
+ .PP
23
+ This defaults to "config.ru" in APP_ROOT.
24
+ It should be the same file used by rackup(1) and other Rack launchers,
25
+ it uses the \f[I]Rack::Builder\f[] DSL.
26
+ .PP
27
+ Embedded command\-line options are mostly parsed for compatibility with
28
+ rackup(1) but strongly discouraged.
29
+ .SH UNICORN OPTIONS
30
+ .TP
31
+ .B \-c, \-\-config\-file CONFIG_FILE
32
+ Path to the Unicorn\-specific config file.
33
+ The config file is implemented as a Ruby DSL, so Ruby code may executed.
34
+ See the RDoc/ri for the \f[I]Unicorn::Configurator\f[] class for the
35
+ full list of directives available from the DSL.
36
+ Using an absolute path for for CONFIG_FILE is recommended as it makes
37
+ multiple instances of Unicorn easily distinguishable when viewing ps(1)
38
+ output.
39
+ .RS
40
+ .RE
41
+ .TP
42
+ .B \-D, \-\-daemonize
43
+ Run daemonized in the background.
44
+ The process is detached from the controlling terminal and stdin is
45
+ redirected to "/dev/null".
46
+ Unlike many common UNIX daemons, we do not chdir to "/" upon
47
+ daemonization to allow more control over the startup/upgrade process.
48
+ Unless specified in the CONFIG_FILE, stderr and stdout will also be
49
+ redirected to "/dev/null".
50
+ .RS
51
+ .RE
52
+ .TP
53
+ .B \-E, \-\-env RACK_ENV
54
+ Run under the given RACK_ENV.
55
+ See the RACK ENVIRONMENT section for more details.
56
+ .RS
57
+ .RE
58
+ .TP
59
+ .B \-l, \-\-listen ADDRESS
60
+ Listens on a given ADDRESS.
61
+ ADDRESS may be in the form of HOST:PORT or PATH, HOST:PORT is taken to
62
+ mean a TCP socket and PATH is meant to be a path to a UNIX domain
63
+ socket.
64
+ Defaults to "0.0.0.0:8080" (all addresses on TCP port 8080) For
65
+ production deployments, specifying the "listen" directive in CONFIG_FILE
66
+ is recommended as it allows fine\-tuning of socket options.
67
+ \-N, \-\-no\-default\-middleware
68
+ .RS
69
+ .RE
70
+ Disables loading middleware implied by RACK_ENV.
71
+ This bypasses the configuration documented in the RACK ENVIRONMENT
72
+ section, but still allows RACK_ENV to be used for
73
+ application/framework\-specific purposes.
74
+ .RS
75
+ .RE
76
+ .SH RACKUP COMPATIBILITY OPTIONS
77
+ .TP
78
+ .B \-o, \-\-host HOST
79
+ Listen on a TCP socket belonging to HOST, default is "0.0.0.0" (all
80
+ addresses).
81
+ If specified multiple times on the command\-line, only the
82
+ last\-specified value takes effect.
83
+ This option only exists for compatibility with the rackup(1) command,
84
+ use of "\-l"/"\-\-listen" switch is recommended instead.
85
+ .RS
86
+ .RE
87
+ .TP
88
+ .B \-p, \-\-port PORT
89
+ Listen on the specified TCP PORT, default is 8080.
90
+ If specified multiple times on the command\-line, only the
91
+ last\-specified value takes effect.
92
+ This option only exists for compatibility with the rackup(1) command,
93
+ use of "\-l"/"\-\-listen" switch is recommended instead.
94
+ .RS
95
+ .RE
96
+ .TP
97
+ .B \-s, \-\-server SERVER
98
+ No\-op, this exists only for compatibility with rackup(1).
99
+ .RS
100
+ .RE
101
+ .SH RUBY OPTIONS
102
+ .TP
103
+ .B \-e, \-\-eval LINE
104
+ Evaluate a LINE of Ruby code.
105
+ This evaluation happens immediately as the command\-line is being
106
+ parsed.
107
+ .RS
108
+ .RE
109
+ .TP
110
+ .B \-d, \-\-debug
111
+ Turn on debug mode, the $DEBUG variable is set to true.
112
+ .RS
113
+ .RE
114
+ .TP
115
+ .B \-w, \-\-warn
116
+ Turn on verbose warnings, the $VERBOSE variable is set to true.
117
+ .RS
118
+ .RE
119
+ .TP
120
+ .B \-I, \-\-include PATH
121
+ specify $LOAD_PATH.
122
+ PATH will be prepended to $LOAD_PATH.
123
+ The \[aq]:\[aq] character may be used to delimit multiple directories.
124
+ This directive may be used more than once.
125
+ Modifications to $LOAD_PATH take place immediately and in the order they
126
+ were specified on the command\-line.
127
+ .RS
128
+ .RE
129
+ .TP
130
+ .B \-r, \-\-require LIBRARY
131
+ require a specified LIBRARY before executing the application.
132
+ The "require" statement will be executed immediately and in the order
133
+ they were specified on the command\-line.
134
+ .RS
135
+ .RE
136
+ .SH SIGNALS
137
+ .PP
138
+ The following UNIX signals may be sent to the master process:
139
+ .IP \[bu] 2
140
+ HUP \- reload config file, app, and gracefully restart all workers
141
+ .IP \[bu] 2
142
+ INT/TERM \- quick shutdown, kills all workers immediately
143
+ .IP \[bu] 2
144
+ QUIT \- graceful shutdown, waits for workers to finish their current
145
+ request before finishing.
146
+ .IP \[bu] 2
147
+ USR1 \- reopen all logs owned by the master and all workers See
148
+ Unicorn::Util.reopen_logs for what is considered a log.
149
+ .IP \[bu] 2
150
+ USR2 \- reexecute the running binary.
151
+ A separate QUIT should be sent to the original process once the child is
152
+ verified to be up and running.
153
+ .IP \[bu] 2
154
+ WINCH \- gracefully stops workers but keep the master running.
155
+ This will only work for daemonized processes.
156
+ .IP \[bu] 2
157
+ TTIN \- increment the number of worker processes by one
158
+ .IP \[bu] 2
159
+ TTOU \- decrement the number of worker processes by one
160
+ .PP
161
+ See the SIGNALS (https://bogomips.org/unicorn/SIGNALS.html) document for
162
+ full description of all signals used by Unicorn.
163
+ .SH RACK ENVIRONMENT
164
+ .PP
165
+ Accepted values of RACK_ENV and the middleware they automatically load
166
+ (outside of RACKUP_FILE) are exactly as those in rackup(1):
167
+ .IP \[bu] 2
168
+ development \- loads Rack::CommonLogger, Rack::ShowExceptions, and
169
+ Rack::Lint middleware
170
+ .IP \[bu] 2
171
+ deployment \- loads Rack::CommonLogger middleware
172
+ .IP \[bu] 2
173
+ none \- loads no middleware at all, relying entirely on RACKUP_FILE
174
+ .PP
175
+ All unrecognized values for RACK_ENV are assumed to be "none".
176
+ Production deployments are strongly encouraged to use "deployment" or
177
+ "none" for maximum performance.
178
+ .PP
179
+ As of Unicorn 0.94.0, RACK_ENV is exported as a process\-wide
180
+ environment variable as well.
181
+ While not current a part of the Rack specification as of Rack 1.0.1,
182
+ this has become a de facto standard in the Rack world.
183
+ .PP
184
+ Note the Rack::ContentLength and Rack::Chunked middlewares are also
185
+ loaded by "deployment" and "development", but no other values of
186
+ RACK_ENV.
187
+ If needed, they must be individually specified in the RACKUP_FILE, some
188
+ frameworks do not require them.
189
+ .SH ENVIRONMENT VARIABLES
190
+ .PP
191
+ The RACK_ENV variable is set by the aforementioned \-E switch.
192
+ All application or library\-specific environment variables (e.g.
193
+ TMPDIR) may always be set in the Unicorn CONFIG_FILE in addition to the
194
+ spawning shell.
195
+ When transparently upgrading Unicorn, all environment variables set in
196
+ the old master process are inherited by the new master process.
197
+ Unicorn only uses (and will overwrite) the UNICORN_FD environment
198
+ variable internally when doing transparent upgrades.
199
+ .PP
200
+ UNICORN_FD is a comma\-delimited list of one or more file descriptors
201
+ used to implement USR2 upgrades.
202
+ Init systems may bind listen sockets itself and spawn unicorn with
203
+ UNICORN_FD set to the file descriptor numbers of the listen socket(s).
204
+ .PP
205
+ As of unicorn 5.0, LISTEN_PID and LISTEN_FDS are used for socket
206
+ activation as documented in the sd_listen_fds(3) manpage.
207
+ Users relying on this feature do not need to specify a listen socket in
208
+ the unicorn config file.
209
+ .SH SEE ALSO
210
+ .IP \[bu] 2
211
+ \f[I]Rack::Builder\f[] ri/RDoc
212
+ .IP \[bu] 2
213
+ \f[I]Unicorn::Configurator\f[] ri/RDoc
214
+ .IP \[bu] 2
215
+ Unicorn RDoc (https://bogomips.org/unicorn/)
216
+ .IP \[bu] 2
217
+ Rack RDoc (http://www.rubydoc.info/github/rack/rack/)
218
+ .IP \[bu] 2
219
+ Rackup HowTo (https://github.com/rack/rack/wiki/tutorial-rackup-howto)
220
+ .SH AUTHORS
221
+ The Unicorn Community <unicorn-public@bogomips.org>.