puma 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puma might be problematic. Click here for more details.
- data/History.txt +7 -0
- data/lib/puma/cli.rb +89 -40
- data/lib/puma/const.rb +1 -1
- data/lib/puma/daemon_ext.rb +1 -1
- data/lib/puma/jruby_restart.rb +38 -0
- data/puma.gemspec +9 -9
- data/test/test_integration.rb +5 -1
- metadata +11 -6
data/History.txt
CHANGED
data/lib/puma/cli.rb
CHANGED
@@ -39,9 +39,6 @@ module Puma
|
|
39
39
|
@restart = false
|
40
40
|
@phased_state = :idle
|
41
41
|
|
42
|
-
@io_redirected = false
|
43
|
-
|
44
|
-
|
45
42
|
ENV['NEWRELIC_DISPATCHER'] ||= "puma"
|
46
43
|
|
47
44
|
setup_options
|
@@ -366,7 +363,6 @@ module Puma
|
|
366
363
|
append = @options[:redirect_append]
|
367
364
|
|
368
365
|
if stdout
|
369
|
-
@io_redirected = true
|
370
366
|
STDOUT.reopen stdout, (append ? "a" : "w")
|
371
367
|
STDOUT.sync = true
|
372
368
|
STDOUT.puts "=== puma startup: #{Time.now} ==="
|
@@ -409,64 +405,117 @@ module Puma
|
|
409
405
|
end
|
410
406
|
end
|
411
407
|
|
412
|
-
def
|
408
|
+
def daemon?
|
409
|
+
@options[:daemon]
|
410
|
+
end
|
411
|
+
|
412
|
+
def jruby_daemon?
|
413
|
+
daemon? and jruby?
|
414
|
+
end
|
415
|
+
|
416
|
+
def output_header
|
413
417
|
min_t = @options[:min_threads]
|
414
418
|
max_t = @options[:max_threads]
|
415
419
|
|
416
420
|
log "Puma #{Puma::Const::PUMA_VERSION} starting..."
|
417
421
|
log "* Min threads: #{min_t}, max threads: #{max_t}"
|
418
422
|
log "* Environment: #{ENV['RACK_ENV']}"
|
423
|
+
end
|
419
424
|
|
420
|
-
|
425
|
+
def start_control(server, str)
|
426
|
+
require 'puma/app/status'
|
421
427
|
|
422
|
-
|
423
|
-
error "No application configured, nothing to run"
|
424
|
-
exit 1
|
425
|
-
end
|
428
|
+
uri = URI.parse str
|
426
429
|
|
427
|
-
|
428
|
-
|
430
|
+
app = Puma::App::Status.new server, self
|
431
|
+
|
432
|
+
if token = @options[:control_auth_token]
|
433
|
+
app.auth_token = token unless token.empty? or token == :none
|
429
434
|
end
|
430
435
|
|
431
|
-
|
436
|
+
status = Puma::Server.new app, @events
|
437
|
+
status.min_threads = 0
|
438
|
+
status.max_threads = 1
|
432
439
|
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
440
|
+
case uri.scheme
|
441
|
+
when "tcp"
|
442
|
+
log "* Starting status server on #{str}"
|
443
|
+
status.add_tcp_listener uri.host, uri.port
|
444
|
+
when "unix"
|
445
|
+
log "* Starting status server on #{str}"
|
446
|
+
path = "#{uri.host}#{uri.path}"
|
437
447
|
|
438
|
-
|
448
|
+
status.add_unix_listener path
|
449
|
+
else
|
450
|
+
error "Invalid status URI: #{str}"
|
451
|
+
end
|
439
452
|
|
440
|
-
|
441
|
-
|
453
|
+
status.run
|
454
|
+
@status = status
|
455
|
+
end
|
442
456
|
|
443
|
-
|
457
|
+
def run_single
|
458
|
+
already_daemon = false
|
444
459
|
|
445
|
-
|
460
|
+
if jruby_daemon?
|
461
|
+
require 'puma/jruby_restart'
|
446
462
|
|
447
|
-
if
|
448
|
-
|
463
|
+
if JRubyRestart.daemon?
|
464
|
+
# Bind before redirecting IO so binding errors show up on stdout/stderr
|
465
|
+
@binder.parse @options[:binds], self
|
449
466
|
end
|
450
467
|
|
451
|
-
|
452
|
-
|
453
|
-
status.max_threads = 1
|
468
|
+
already_daemon = JRubyRestart.daemon_init
|
469
|
+
end
|
454
470
|
|
455
|
-
|
456
|
-
when "tcp"
|
457
|
-
log "* Starting status server on #{str}"
|
458
|
-
status.add_tcp_listener uri.host, uri.port
|
459
|
-
when "unix"
|
460
|
-
log "* Starting status server on #{str}"
|
461
|
-
path = "#{uri.host}#{uri.path}"
|
471
|
+
output_header
|
462
472
|
|
463
|
-
|
464
|
-
|
465
|
-
|
473
|
+
if !jruby_daemon?
|
474
|
+
@binder.parse @options[:binds], self
|
475
|
+
end
|
476
|
+
|
477
|
+
unless @config.app_configured?
|
478
|
+
error "No application configured, nothing to run"
|
479
|
+
exit 1
|
480
|
+
end
|
481
|
+
|
482
|
+
# Load the app before we daemonize.
|
483
|
+
begin
|
484
|
+
app = @config.app
|
485
|
+
rescue Exception => e
|
486
|
+
log "! Unable to load application"
|
487
|
+
raise e
|
488
|
+
end
|
489
|
+
|
490
|
+
if jruby_daemon?
|
491
|
+
unless already_daemon
|
492
|
+
require 'puma/jruby_restart'
|
493
|
+
|
494
|
+
pid = nil
|
495
|
+
|
496
|
+
Signal.trap "SIGUSR2" do
|
497
|
+
log "* Started new process #{pid} as daemon..."
|
498
|
+
exit
|
499
|
+
end
|
500
|
+
|
501
|
+
pid = JRubyRestart.daemon_start(@restart_dir, @restart_argv)
|
502
|
+
sleep
|
466
503
|
end
|
504
|
+
elsif daemon?
|
505
|
+
Process.daemon(true)
|
506
|
+
end
|
507
|
+
|
508
|
+
write_state
|
509
|
+
|
510
|
+
server = Puma::Server.new app, @events
|
511
|
+
server.binder = @binder
|
512
|
+
server.min_threads = @options[:min_threads]
|
513
|
+
server.max_threads = @options[:max_threads]
|
467
514
|
|
468
|
-
|
469
|
-
|
515
|
+
@server = server
|
516
|
+
|
517
|
+
if str = @options[:control_url]
|
518
|
+
start_control server, str
|
470
519
|
end
|
471
520
|
|
472
521
|
begin
|
@@ -726,7 +775,7 @@ module Puma
|
|
726
775
|
@check_pipe, @suicide_pipe = Puma::Util.pipe
|
727
776
|
|
728
777
|
if @options[:daemon]
|
729
|
-
Process.daemon(true
|
778
|
+
Process.daemon(true)
|
730
779
|
else
|
731
780
|
log "Use Ctrl-C to stop"
|
732
781
|
end
|
data/lib/puma/const.rb
CHANGED
data/lib/puma/daemon_ext.rb
CHANGED
data/lib/puma/jruby_restart.rb
CHANGED
@@ -7,6 +7,9 @@ module Puma
|
|
7
7
|
|
8
8
|
attach_function :execlp, [:string, :varargs], :int
|
9
9
|
attach_function :chdir, [:string], :int
|
10
|
+
attach_function :fork, [], :int
|
11
|
+
attach_function :exit, [:int], :void
|
12
|
+
attach_function :setsid, [], :int
|
10
13
|
|
11
14
|
def self.chdir_exec(dir, argv)
|
12
15
|
chdir(dir)
|
@@ -17,6 +20,41 @@ module Puma
|
|
17
20
|
execlp(cmd, *argv)
|
18
21
|
raise SystemCallError.new(FFI.errno)
|
19
22
|
end
|
23
|
+
|
24
|
+
def self.daemon?
|
25
|
+
ENV.key? 'PUMA_DAEMON_RESTART'
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.daemon_init
|
29
|
+
return false unless ENV.key? 'PUMA_DAEMON_RESTART'
|
30
|
+
|
31
|
+
master = ENV['PUMA_DAEMON_RESTART']
|
32
|
+
Process.kill "SIGUSR2", master.to_i
|
33
|
+
|
34
|
+
setsid
|
35
|
+
|
36
|
+
null = File.open "/dev/null", "w+"
|
37
|
+
STDIN.reopen null
|
38
|
+
STDOUT.reopen null
|
39
|
+
STDERR.reopen null
|
40
|
+
|
41
|
+
true
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.daemon_start(dir, argv)
|
45
|
+
ENV['PUMA_DAEMON_RESTART'] = Process.pid.to_s
|
46
|
+
|
47
|
+
cmd = argv.first
|
48
|
+
argv = ([:string] * argv.size).zip(argv).flatten
|
49
|
+
argv << :string
|
50
|
+
argv << nil
|
51
|
+
|
52
|
+
chdir(dir)
|
53
|
+
ret = fork
|
54
|
+
return ret if ret != 0
|
55
|
+
execlp(cmd, *argv)
|
56
|
+
raise SystemCallError.new(FFI.errno)
|
57
|
+
end
|
20
58
|
end
|
21
59
|
end
|
22
60
|
|
data/puma.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "puma"
|
5
|
-
s.version = "2.1.
|
5
|
+
s.version = "2.1.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Evan Phoenix"]
|
9
|
-
s.date = "2013-06-
|
9
|
+
s.date = "2013-06-20"
|
10
10
|
s.description = "Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications. Puma is intended for use in both development and production environments. In order to get the best throughput, it is highly recommended that you use a Ruby implementation with real threads like Rubinius or JRuby."
|
11
11
|
s.email = ["evan@phx.io"]
|
12
12
|
s.executables = ["puma", "pumactl"]
|
13
13
|
s.extensions = ["ext/puma_http11/extconf.rb"]
|
14
|
-
s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
|
14
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.md", "docs/config.md", "docs/nginx.md", "tools/jungle/init.d/README.md", "tools/jungle/upstart/README.md"]
|
15
15
|
s.files = ["COPYING", "Gemfile", "History.txt", "LICENSE", "Manifest.txt", "README.md", "Rakefile", "TODO", "bin/puma", "bin/pumactl", "docs/config.md", "docs/nginx.md", "ext/puma_http11/PumaHttp11Service.java", "ext/puma_http11/ext_help.h", "ext/puma_http11/extconf.rb", "ext/puma_http11/http11_parser.c", "ext/puma_http11/http11_parser.h", "ext/puma_http11/http11_parser.java.rl", "ext/puma_http11/http11_parser.rl", "ext/puma_http11/http11_parser_common.rl", "ext/puma_http11/io_buffer.c", "ext/puma_http11/mini_ssl.c", "ext/puma_http11/org/jruby/puma/Http11.java", "ext/puma_http11/org/jruby/puma/Http11Parser.java", "ext/puma_http11/org/jruby/puma/MiniSSL.java", "ext/puma_http11/puma_http11.c", "lib/puma.rb", "lib/puma/accept_nonblock.rb", "lib/puma/app/status.rb", "lib/puma/binder.rb", "lib/puma/capistrano.rb", "lib/puma/cli.rb", "lib/puma/client.rb", "lib/puma/compat.rb", "lib/puma/configuration.rb", "lib/puma/const.rb", "lib/puma/control_cli.rb", "lib/puma/daemon_ext.rb", "lib/puma/delegation.rb", "lib/puma/detect.rb", "lib/puma/events.rb", "lib/puma/io_buffer.rb", "lib/puma/java_io_buffer.rb", "lib/puma/jruby_restart.rb", "lib/puma/minissl.rb", "lib/puma/null_io.rb", "lib/puma/rack_default.rb", "lib/puma/rack_patch.rb", "lib/puma/reactor.rb", "lib/puma/server.rb", "lib/puma/thread_pool.rb", "lib/puma/util.rb", "lib/rack/handler/puma.rb", "puma.gemspec", "tools/jungle/init.d/README.md", "tools/jungle/init.d/puma", "tools/jungle/init.d/run-puma", "tools/jungle/upstart/README.md", "tools/jungle/upstart/puma-manager.conf", "tools/jungle/upstart/puma.conf", "test/test_app_status.rb", "test/test_cli.rb", "test/test_config.rb", "test/test_http10.rb", "test/test_http11.rb", "test/test_integration.rb", "test/test_iobuffer.rb", "test/test_minissl.rb", "test/test_null_io.rb", "test/test_persistent.rb", "test/test_puma_server.rb", "test/test_rack_handler.rb", "test/test_rack_server.rb", "test/test_thread_pool.rb", "test/test_unix_socket.rb", "test/test_ws.rb"]
|
16
16
|
s.homepage = "http://puma.io"
|
17
17
|
s.rdoc_options = ["--main", "README.md"]
|
@@ -27,19 +27,19 @@ Gem::Specification.new do |s|
|
|
27
27
|
|
28
28
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
29
29
|
s.add_runtime_dependency(%q<rack>, ["< 2.0", ">= 1.1"])
|
30
|
-
s.add_development_dependency(%q<rdoc>, ["~>
|
30
|
+
s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
|
31
31
|
s.add_development_dependency(%q<rake-compiler>, ["~> 0.8.0"])
|
32
|
-
s.add_development_dependency(%q<hoe>, ["~> 3.
|
32
|
+
s.add_development_dependency(%q<hoe>, ["~> 3.6"])
|
33
33
|
else
|
34
34
|
s.add_dependency(%q<rack>, ["< 2.0", ">= 1.1"])
|
35
|
-
s.add_dependency(%q<rdoc>, ["~>
|
35
|
+
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
36
36
|
s.add_dependency(%q<rake-compiler>, ["~> 0.8.0"])
|
37
|
-
s.add_dependency(%q<hoe>, ["~> 3.
|
37
|
+
s.add_dependency(%q<hoe>, ["~> 3.6"])
|
38
38
|
end
|
39
39
|
else
|
40
40
|
s.add_dependency(%q<rack>, ["< 2.0", ">= 1.1"])
|
41
|
-
s.add_dependency(%q<rdoc>, ["~>
|
41
|
+
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
42
42
|
s.add_dependency(%q<rake-compiler>, ["~> 0.8.0"])
|
43
|
-
s.add_dependency(%q<hoe>, ["~> 3.
|
43
|
+
s.add_dependency(%q<hoe>, ["~> 3.6"])
|
44
44
|
end
|
45
45
|
end
|
data/test/test_integration.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
43
|
+
version: '4.0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
46
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
requirements:
|
49
49
|
- - ~>
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: '
|
51
|
+
version: '4.0'
|
52
52
|
- !ruby/object:Gem::Dependency
|
53
53
|
name: rake-compiler
|
54
54
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,7 +72,7 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
75
|
+
version: '3.6'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
requirements:
|
81
81
|
- - ~>
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '3.
|
83
|
+
version: '3.6'
|
84
84
|
description: Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server
|
85
85
|
for Ruby/Rack applications. Puma is intended for use in both development and production
|
86
86
|
environments. In order to get the best throughput, it is highly recommended that
|
@@ -95,6 +95,11 @@ extensions:
|
|
95
95
|
extra_rdoc_files:
|
96
96
|
- History.txt
|
97
97
|
- Manifest.txt
|
98
|
+
- README.md
|
99
|
+
- docs/config.md
|
100
|
+
- docs/nginx.md
|
101
|
+
- tools/jungle/init.d/README.md
|
102
|
+
- tools/jungle/upstart/README.md
|
98
103
|
files:
|
99
104
|
- COPYING
|
100
105
|
- Gemfile
|