jun-puma 1.0.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/History.md +2897 -0
  3. data/LICENSE +29 -0
  4. data/README.md +475 -0
  5. data/bin/puma +10 -0
  6. data/bin/puma-wild +25 -0
  7. data/bin/pumactl +12 -0
  8. data/docs/architecture.md +74 -0
  9. data/docs/compile_options.md +55 -0
  10. data/docs/deployment.md +102 -0
  11. data/docs/fork_worker.md +35 -0
  12. data/docs/images/puma-connection-flow-no-reactor.png +0 -0
  13. data/docs/images/puma-connection-flow.png +0 -0
  14. data/docs/images/puma-general-arch.png +0 -0
  15. data/docs/jungle/README.md +9 -0
  16. data/docs/jungle/rc.d/README.md +74 -0
  17. data/docs/jungle/rc.d/puma +61 -0
  18. data/docs/jungle/rc.d/puma.conf +10 -0
  19. data/docs/kubernetes.md +78 -0
  20. data/docs/nginx.md +80 -0
  21. data/docs/plugins.md +38 -0
  22. data/docs/rails_dev_mode.md +28 -0
  23. data/docs/restart.md +65 -0
  24. data/docs/signals.md +98 -0
  25. data/docs/stats.md +142 -0
  26. data/docs/systemd.md +253 -0
  27. data/docs/testing_benchmarks_local_files.md +150 -0
  28. data/docs/testing_test_rackup_ci_files.md +36 -0
  29. data/ext/puma_http11/PumaHttp11Service.java +17 -0
  30. data/ext/puma_http11/ext_help.h +15 -0
  31. data/ext/puma_http11/extconf.rb +80 -0
  32. data/ext/puma_http11/http11_parser.c +1057 -0
  33. data/ext/puma_http11/http11_parser.h +65 -0
  34. data/ext/puma_http11/http11_parser.java.rl +145 -0
  35. data/ext/puma_http11/http11_parser.rl +149 -0
  36. data/ext/puma_http11/http11_parser_common.rl +54 -0
  37. data/ext/puma_http11/mini_ssl.c +842 -0
  38. data/ext/puma_http11/no_ssl/PumaHttp11Service.java +15 -0
  39. data/ext/puma_http11/org/jruby/puma/Http11.java +228 -0
  40. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +455 -0
  41. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +509 -0
  42. data/ext/puma_http11/puma_http11.c +495 -0
  43. data/lib/puma/app/status.rb +96 -0
  44. data/lib/puma/binder.rb +502 -0
  45. data/lib/puma/cli.rb +247 -0
  46. data/lib/puma/client.rb +682 -0
  47. data/lib/puma/cluster/worker.rb +180 -0
  48. data/lib/puma/cluster/worker_handle.rb +96 -0
  49. data/lib/puma/cluster.rb +616 -0
  50. data/lib/puma/commonlogger.rb +115 -0
  51. data/lib/puma/configuration.rb +390 -0
  52. data/lib/puma/const.rb +307 -0
  53. data/lib/puma/control_cli.rb +316 -0
  54. data/lib/puma/detect.rb +45 -0
  55. data/lib/puma/dsl.rb +1425 -0
  56. data/lib/puma/error_logger.rb +113 -0
  57. data/lib/puma/events.rb +57 -0
  58. data/lib/puma/io_buffer.rb +46 -0
  59. data/lib/puma/jruby_restart.rb +11 -0
  60. data/lib/puma/json_serialization.rb +96 -0
  61. data/lib/puma/launcher/bundle_pruner.rb +104 -0
  62. data/lib/puma/launcher.rb +488 -0
  63. data/lib/puma/log_writer.rb +147 -0
  64. data/lib/puma/minissl/context_builder.rb +96 -0
  65. data/lib/puma/minissl.rb +459 -0
  66. data/lib/puma/null_io.rb +84 -0
  67. data/lib/puma/plugin/systemd.rb +90 -0
  68. data/lib/puma/plugin/tmp_restart.rb +36 -0
  69. data/lib/puma/plugin.rb +111 -0
  70. data/lib/puma/puma_http11.jar +0 -0
  71. data/lib/puma/rack/builder.rb +297 -0
  72. data/lib/puma/rack/urlmap.rb +93 -0
  73. data/lib/puma/rack_default.rb +24 -0
  74. data/lib/puma/reactor.rb +125 -0
  75. data/lib/puma/request.rb +688 -0
  76. data/lib/puma/runner.rb +213 -0
  77. data/lib/puma/sd_notify.rb +149 -0
  78. data/lib/puma/server.rb +680 -0
  79. data/lib/puma/single.rb +69 -0
  80. data/lib/puma/state_file.rb +68 -0
  81. data/lib/puma/thread_pool.rb +434 -0
  82. data/lib/puma/util.rb +141 -0
  83. data/lib/puma.rb +78 -0
  84. data/lib/rack/handler/puma.rb +144 -0
  85. data/tools/Dockerfile +16 -0
  86. data/tools/trickletest.rb +44 -0
  87. metadata +153 -0
data/lib/puma/cli.rb ADDED
@@ -0,0 +1,247 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'optparse'
4
+ require 'uri'
5
+
6
+ require_relative '../puma'
7
+ require_relative 'configuration'
8
+ require_relative 'launcher'
9
+ require_relative 'const'
10
+ require_relative 'log_writer'
11
+
12
+ module Puma
13
+ class << self
14
+ # The CLI exports a Puma::Configuration instance here to allow
15
+ # apps to pick it up. An app must load this object conditionally
16
+ # because it is not set if the app is launched via any mechanism
17
+ # other than the CLI class.
18
+ attr_accessor :cli_config
19
+ end
20
+
21
+ # Handles invoke a Puma::Server in a command line style.
22
+ #
23
+ class CLI
24
+ # Create a new CLI object using +argv+ as the command line
25
+ # arguments.
26
+ #
27
+ def initialize(argv, log_writer = LogWriter.stdio, events = Events.new, env: ENV)
28
+ @debug = false
29
+ @argv = argv.dup
30
+ @log_writer = log_writer
31
+ @events = events
32
+
33
+ @conf = nil
34
+
35
+ @stdout = nil
36
+ @stderr = nil
37
+ @append = false
38
+
39
+ @control_url = nil
40
+ @control_options = {}
41
+
42
+ setup_options env
43
+
44
+ begin
45
+ @parser.parse! @argv
46
+
47
+ if file = @argv.shift
48
+ @conf.configure do |user_config, file_config|
49
+ file_config.rackup file
50
+ end
51
+ end
52
+ rescue UnsupportedOption
53
+ exit 1
54
+ end
55
+
56
+ @conf.configure do |user_config, file_config|
57
+ if @stdout || @stderr
58
+ user_config.stdout_redirect @stdout, @stderr, @append
59
+ end
60
+
61
+ if @control_url
62
+ user_config.activate_control_app @control_url, @control_options
63
+ end
64
+ end
65
+
66
+ @launcher = Puma::Launcher.new(@conf, env: ENV, log_writer: @log_writer, events: @events, argv: argv)
67
+ end
68
+
69
+ attr_reader :launcher
70
+
71
+ # Parse the options, load the rackup, start the server and wait
72
+ # for it to finish.
73
+ #
74
+ def run
75
+ @launcher.run
76
+ end
77
+
78
+ private
79
+ def unsupported(str)
80
+ @log_writer.error(str)
81
+ raise UnsupportedOption
82
+ end
83
+
84
+ def configure_control_url(command_line_arg)
85
+ if command_line_arg
86
+ @control_url = command_line_arg
87
+ elsif Puma.jruby?
88
+ unsupported "No default url available on JRuby"
89
+ end
90
+ end
91
+
92
+ # Build the OptionParser object to handle the available options.
93
+ #
94
+
95
+ def setup_options(env = ENV)
96
+ @conf = Configuration.new({}, {events: @events}, env) do |user_config, file_config|
97
+ @parser = OptionParser.new do |o|
98
+ o.on "-b", "--bind URI", "URI to bind to (tcp://, unix://, ssl://)" do |arg|
99
+ user_config.bind arg
100
+ end
101
+
102
+ o.on "--bind-to-activated-sockets [only]", "Bind to all activated sockets" do |arg|
103
+ user_config.bind_to_activated_sockets(arg || true)
104
+ end
105
+
106
+ o.on "-C", "--config PATH", "Load PATH as a config file" do |arg|
107
+ file_config.load arg
108
+ end
109
+
110
+ # Identical to supplying --config "-", but more semantic
111
+ o.on "--no-config", "Prevent Puma from searching for a config file" do |arg|
112
+ file_config.load "-"
113
+ end
114
+
115
+ o.on "--control-url URL", "The bind url to use for the control server. Use 'auto' to use temp unix server" do |arg|
116
+ configure_control_url(arg)
117
+ end
118
+
119
+ o.on "--control-token TOKEN",
120
+ "The token to use as authentication for the control server" do |arg|
121
+ @control_options[:auth_token] = arg
122
+ end
123
+
124
+ o.on "--debug", "Log lowlevel debugging information" do
125
+ user_config.debug
126
+ end
127
+
128
+ o.on "--dir DIR", "Change to DIR before starting" do |d|
129
+ user_config.directory d
130
+ end
131
+
132
+ o.on "-e", "--environment ENVIRONMENT",
133
+ "The environment to run the Rack app on (default development)" do |arg|
134
+ user_config.environment arg
135
+ end
136
+
137
+ o.on "-f", "--fork-worker=[REQUESTS]", OptionParser::DecimalInteger,
138
+ "Fork new workers from existing worker. Cluster mode only",
139
+ "Auto-refork after REQUESTS (default 1000)" do |*args|
140
+ user_config.fork_worker(*args.compact)
141
+ end
142
+
143
+ o.on "-I", "--include PATH", "Specify $LOAD_PATH directories" do |arg|
144
+ $LOAD_PATH.unshift(*arg.split(':'))
145
+ end
146
+
147
+ o.on "--idle-timeout SECONDS", "Number of seconds until the next request before automatic shutdown" do |arg|
148
+ user_config.idle_timeout arg
149
+ end
150
+
151
+ o.on "-p", "--port PORT", "Define the TCP port to bind to",
152
+ "Use -b for more advanced options" do |arg|
153
+ user_config.bind "tcp://#{Configuration::DEFAULTS[:tcp_host]}:#{arg}"
154
+ end
155
+
156
+ o.on "--pidfile PATH", "Use PATH as a pidfile" do |arg|
157
+ user_config.pidfile arg
158
+ end
159
+
160
+ o.on "--plugin PLUGIN", "Load the given PLUGIN. Can be used multiple times to load multiple plugins." do |arg|
161
+ user_config.plugin arg
162
+ end
163
+
164
+ o.on "--preload", "Preload the app. Cluster mode only" do
165
+ user_config.preload_app!
166
+ end
167
+
168
+ o.on "--prune-bundler", "Prune out the bundler env if possible" do
169
+ user_config.prune_bundler
170
+ end
171
+
172
+ o.on "--extra-runtime-dependencies GEM1,GEM2", "Defines any extra needed gems when using --prune-bundler" do |arg|
173
+ user_config.extra_runtime_dependencies arg.split(',')
174
+ end
175
+
176
+ o.on "-q", "--quiet", "Do not log requests internally (default true)" do
177
+ user_config.quiet
178
+ end
179
+
180
+ o.on "-v", "--log-requests", "Log requests as they occur" do
181
+ user_config.log_requests
182
+ end
183
+
184
+ o.on "-R", "--restart-cmd CMD",
185
+ "The puma command to run during a hot restart",
186
+ "Default: inferred" do |cmd|
187
+ user_config.restart_command cmd
188
+ end
189
+
190
+ o.on "-s", "--silent", "Do not log prompt messages other than errors" do
191
+ @log_writer = LogWriter.new(NullIO.new, $stderr)
192
+ end
193
+
194
+ o.on "-S", "--state PATH", "Where to store the state details" do |arg|
195
+ user_config.state_path arg
196
+ end
197
+
198
+ o.on '-t', '--threads INT', "min:max threads to use (default 0:16)" do |arg|
199
+ min, max = arg.split(":")
200
+ if max
201
+ user_config.threads min, max
202
+ else
203
+ user_config.threads min, min
204
+ end
205
+ end
206
+
207
+ o.on "--early-hints", "Enable early hints support" do
208
+ user_config.early_hints
209
+ end
210
+
211
+ o.on "-V", "--version", "Print the version information" do
212
+ puts "puma version #{Puma::Const::VERSION}"
213
+ exit 0
214
+ end
215
+
216
+ o.on "-w", "--workers COUNT",
217
+ "Activate cluster mode: How many worker processes to create" do |arg|
218
+ user_config.workers arg
219
+ end
220
+
221
+ o.on "--tag NAME", "Additional text to display in process listing" do |arg|
222
+ user_config.tag arg
223
+ end
224
+
225
+ o.on "--redirect-stdout FILE", "Redirect STDOUT to a specific file" do |arg|
226
+ @stdout = arg.to_s
227
+ end
228
+
229
+ o.on "--redirect-stderr FILE", "Redirect STDERR to a specific file" do |arg|
230
+ @stderr = arg.to_s
231
+ end
232
+
233
+ o.on "--[no-]redirect-append", "Append to redirected files" do |val|
234
+ @append = val
235
+ end
236
+
237
+ o.banner = "puma <options> <rackup file>"
238
+
239
+ o.on_tail "-h", "--help", "Show help" do
240
+ $stdout.puts o
241
+ exit 0
242
+ end
243
+ end
244
+ end
245
+ end
246
+ end
247
+ end