puma 2.1.0-java → 2.1.1-java

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.

@@ -1,3 +1,10 @@
1
+ === 2.1.1 / 2013-06-20
2
+
3
+ * 2 minor bug fixes:
4
+
5
+ * Fix daemonization on jruby
6
+ * Load the application before daemonizing. Fixes #285
7
+
1
8
  === 2.1.0 / 2013-06-18
2
9
 
3
10
  * 3 minor features:
@@ -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 run_single
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
- @binder.parse @options[:binds], self
425
+ def start_control(server, str)
426
+ require 'puma/app/status'
421
427
 
422
- unless @config.app_configured?
423
- error "No application configured, nothing to run"
424
- exit 1
425
- end
428
+ uri = URI.parse str
426
429
 
427
- if @options[:daemon]
428
- Process.daemon(true, @io_redirected)
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
- write_state
436
+ status = Puma::Server.new app, @events
437
+ status.min_threads = 0
438
+ status.max_threads = 1
432
439
 
433
- server = Puma::Server.new @config.app, @events
434
- server.binder = @binder
435
- server.min_threads = min_t
436
- server.max_threads = max_t
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
- @server = server
448
+ status.add_unix_listener path
449
+ else
450
+ error "Invalid status URI: #{str}"
451
+ end
439
452
 
440
- if str = @options[:control_url]
441
- require 'puma/app/status'
453
+ status.run
454
+ @status = status
455
+ end
442
456
 
443
- uri = URI.parse str
457
+ def run_single
458
+ already_daemon = false
444
459
 
445
- app = Puma::App::Status.new server, self
460
+ if jruby_daemon?
461
+ require 'puma/jruby_restart'
446
462
 
447
- if token = @options[:control_auth_token]
448
- app.auth_token = token unless token.empty? or token == :none
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
- status = Puma::Server.new app, @events
452
- status.min_threads = 0
453
- status.max_threads = 1
468
+ already_daemon = JRubyRestart.daemon_init
469
+ end
454
470
 
455
- case uri.scheme
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
- status.add_unix_listener path
464
- else
465
- error "Invalid status URI: #{str}"
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
- status.run
469
- @status = status
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, @io_redirected)
778
+ Process.daemon(true)
730
779
  else
731
780
  log "Use Ctrl-C to stop"
732
781
  end
@@ -28,7 +28,7 @@ module Puma
28
28
  # too taxing on performance.
29
29
  module Const
30
30
 
31
- PUMA_VERSION = VERSION = "2.1.0".freeze
31
+ PUMA_VERSION = VERSION = "2.1.1".freeze
32
32
 
33
33
  FAST_TRACK_KA_TIMEOUT = 0.2
34
34
 
@@ -9,7 +9,7 @@ module Process
9
9
  Dir.chdir "/" unless nochdir # Release old working directory.
10
10
 
11
11
  if !noclose
12
- null = File.open "/dev/null"
12
+ null = File.open "/dev/null", "w+"
13
13
  STDIN.reopen null
14
14
  STDOUT.reopen null
15
15
  STDERR.reopen null
@@ -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
 
Binary file
@@ -2,16 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "puma"
5
- s.version = "2.1.0"
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-18"
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>, ["~> 3.10"])
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.5"])
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>, ["~> 3.10"])
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.5"])
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>, ["~> 3.10"])
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.5"])
43
+ s.add_dependency(%q<hoe>, ["~> 3.6"])
44
44
  end
45
45
  end
@@ -28,7 +28,11 @@ class TestIntegration < Test::Unit::TestCase
28
28
 
29
29
  if @server
30
30
  Process.kill "INT", @server.pid
31
- Process.wait @server.pid
31
+ begin
32
+ Process.wait @server.pid
33
+ rescue Errno::ECHILD
34
+ end
35
+
32
36
  @server.close
33
37
  end
34
38
 
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: puma
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.1.0
5
+ version: 2.1.1
6
6
  platform: java
7
7
  authors:
8
8
  - Evan Phoenix
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-18 00:00:00.000000000 Z
12
+ date: 2013-06-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack