Coder Social home page Coder Social logo

puma / puma Goto Github PK

View Code? Open in Web Editor NEW
7.6K 178.0 1.4K 11.18 MB

A Ruby/Rack web server built for parallelism

Home Page: https://puma.io

License: BSD 3-Clause "New" or "Revised" License

Ruby 84.84% Java 5.17% C 7.21% Ragel 1.12% Shell 1.06% PowerShell 0.41% Dockerfile 0.18% Lua 0.02% Batchfile 0.01%
ruby server multithreading rack

puma's Issues

all requests on a single thread

I've just tried puma on a rails 3.1.1 app. I added 'config.threadsafe!' to 'config/environments/production.rb' and get the following output when I boot the app:

⚡ RAILS_ENV=production bundle exec puma --threads 0:3
Puma 0.9.1 starting...
* Min threads: 0, max threads: 3
* Listening on tcp://0.0.0.0:9292
Use Ctrl-C to stop

I then created a controller action that looks like this:

def index
    product.connection.select_all("select sleep(10)")
    render :text => "I should have taken 10 seconds! (id: #{Thread.current.object_id})"
end

If I make 2 concurrent requests they seem to execute serially and the thread ID is identical. Am I missing something?

load error: puma/puma_http11 -- java.lang.UnsatisfiedLinkError

Hi,

I was interested in checking back to Puma since 1.0.0 got released. Locally it works fine and I am not experiencing any issues with JRuby or hanging processes anymore. I wanted to do some basic benchmarking on a fresh Ubuntu-Server install and when I try to boot up Puma in my Rails app, it aborts with the following error:

bundle exec puma
LoadError: load error: puma/puma_http11 -- java.lang.UnsatisfiedLinkError: failed to load shim library, error: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /usr/local/rvm/rubies/jruby-1.6.7/lib/native/x86_64-Linux/libjruby-cext.so)
  require at org/jruby/RubyKernel.java:1033
   (root) at /usr/local/rvm/gems/jruby-1.6.7/gems/puma-1.0.0/lib/puma/server.rb:10
  require at org/jruby/RubyKernel.java:1033
   (root) at /usr/local/rvm/gems/jruby-1.6.7/gems/puma-1.0.0/lib/puma/server.rb:4
  require at org/jruby/RubyKernel.java:1033
   (root) at /usr/local/rvm/gems/jruby-1.6.7/gems/puma-1.0.0/lib/puma/cli.rb:6
     load at org/jruby/RubyKernel.java:1058
   (root) at /usr/local/rvm/gems/jruby-1.6.7/bin/puma:19

Any idea what might be causing this issue? Is it a missing package?

  • Latest JRuby
  • Latest Rails
  • Latest Puma

Thanks!

Listen loop error: #<IOError: closed stream>

I'm experimenting with using puma to run my jruby rails tests via the capybara-puma gem.

On startup I get issue #32 and when the tests finish, I get a bunch of these errors:

Mon Mar 26 12:22:53 -0400 2012: Listen loop error: #<IOError: closed stream>
org/jruby/RubyIO.java:3362:in `select'
/Users/docwhat/.rvm/gems/jruby-1.6.7@cxo/gems/puma-0.9.5-java/lib/puma/server.rb:159:in `run'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:224:in `call'

RACK_ENV not defaulted to 'development' until after config.ru loads

While RACK_ENV defaults to development properly, it's not set until after the config.ru is evaluated, meaning you can't, eg, conditionally load middleware.

Consider the following rackup file. Other servers, including rackup will print development while puma spits out nil.

p ENV['RACK_ENV']
run ->(e){[200,{},[]]}

(PS: puma is awesome. thank you!)

cannot install puma into rbx

This might be a rubinius or rubygems issue, but I'll start here. I'm trying to install puma into rubinius but it doesn't install the dependencies automatically:

$ ruby -v
rubinius 2.0.0dev (1.8.7 e3a8a1ca yyyy-mm-dd JI) [x86_64-apple-darwin11.1.0]
$ gem install puma
Fetching: puma-0.8.1.gem (100%)
ERROR:  Error installing puma:
    puma requires rack (~> 1.3, runtime)

In ruby193 it installs the dependency as you'd expect:

$ gem install puma
Fetching: rack-1.3.5.gem (100%)
Fetching: puma-0.8.1.gem (100%)
Building native extensions.  This could take a while...
Successfully installed rack-1.3.5
Successfully installed puma-0.8.1
2 gems installed

"Deprecation warning: Database connections will not be closed automatically"

I'm using Puma with Sinatra and ActiveRecord, and I've noticed a few lines being written to STDERR which I'm stuck with:

DEPRECATION WARNING: Database connections will not be closed automatically, please close your
database connection at the end of the thread by calling `close` on your
connection.  For example: ActiveRecord::Base.connection.close
. (called from mon_synchronize at /usr/local/lib/ruby/1.9.1/monitor.rb:211)

I'm using MRI, I can't test this on jRuby because less.rb demands therubyracer, which won't compile ⚡ 😞 ⚡

Is there a fix for this?

PIDFile Support

You should drop pid files, or give an option to. Otherwise people are forced to use evil methods to generate a pid file or do more stupid actions.

Can't use sockets with rails

rails s puma works fine, but I get the following when appending -b unix://tmp/sockets/puma.sock:

=> Booting Puma
=> Rails 3.2.2 application starting in development on http://unix://tmp/sockets/puma.sock:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Puma 0.9.4 starting...

  • Min threads: 0, max threads: 16
  • Listening on tcp://unix://tmp/sockets/puma.sock:3000
    Exiting
    /usr/lib/ruby/gems/1.9.1/gems/puma-0.9.4/lib/puma/server.rb:103:in `initialize': getaddrinfo: Name or service not known (SocketError)

Large bodies without content-length header

Puma doesn't seem to handle large bodies (64k) when the response headers don't contain the content-length header. As a result I had a few pages of my application that ended with a "Failed to load resource" in Chrome (and apparently a truncated body sent to the browser) when served by Puma. They worked without issue when served by Thin.
After adding the Rack::ContentLength middleware it works fine with Puma as well.

cannot load such file -- puma/compat

I get the following when running rails s puma on 1.1.0 -- 1.0.0 works fine.

~/code/vm[master]% rails s puma 
/Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- puma/compat (LoadError)
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `block in require'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/puma-1.1.0/lib/puma/server.rb:8:in `<top (required)>'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `block in require'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in `require'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/puma-1.1.0/lib/puma.rb:14:in `<top (required)>'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `require'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `each'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `each'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `require'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.1.3/lib/bundler.rb:119:in `require'
    from /Users/jkmiller/code/vm/config/application.rb:7:in `<top (required)>'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.2/lib/rails/commands.rb:53:in `require'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.2/lib/rails/commands.rb:53:in `block in <top (required)>'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.2/lib/rails/commands.rb:50:in `tap'
    from /Users/jkmiller/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.2/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

HTTP Parse Error

=> Booting Puma
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Puma 0.9.2 starting...
* Min threads: 0, max threads: 16
* Listening on tcp://0.0.0.0:3000
2012-01-06 08:55:26 -0800: HTTP parse error, malformed request (): #<Puma::HttpParserError: HTTP element FIELD_VALUE is longer than the 80 * 1024 allowed length.>
2012-01-06 08:55:26 -0800: ENV: {"rack.version"=>[1, 1], "rack.errors"=>#\>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>true, "SCRIPT_NAME"=>"", "CONTENT_TYPE"=>"", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"0.9.2", "GATEWAY_INTERFACE"=>"CGI/1.2"}

---
2012-01-06 08:55:29 -0800: HTTP parse error, malformed request (): #<Puma::HttpParserError: HTTP element FIELD_VALUE is longer than the 80 * 1024 allowed length.>
2012-01-06 08:55:29 -0800: ENV: {"rack.version"=>[1, 1], "rack.errors"=>#>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>true, "SCRIPT_NAME"=>"", "CONTENT_TYPE"=>"", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"0.9.2", "GATEWAY_INTERFACE"=>"CGI/1.2"}

---
2012-01-06 08:55:47 -0800: HTTP parse error, malformed request (): #<Puma::HttpParserError: HTTP element FIELD_VALUE is longer than the 80 * 1024 allowed length.>
2012-01-06 08:55:47 -0800: ENV: {"rack.version"=>[1, 1], "rack.errors"=>#>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>true, "SCRIPT_NAME"=>"", "CONTENT_TYPE"=>"", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"0.9.2", "GATEWAY_INTERFACE"=>"CGI/1.2"}

---

Ruby Implementations?

I was wondering, while posting a comment on another issue:

Was Puma developed for a specific Ruby implementation? What Ruby implementation do you recommend to use with Puma? Ruby 1.9.3? Rubinius? JRuby? Or any of them? What are the benefits of each?

When concurrency comes to mind, I think of threads. Looking at Puma's help screen I see that it utilizes them. I would assume an implementation where the global interpreter lock isn't present would benefit the most from this app server, in which case that would mean either Rubinius or JRuby. (Not sure whether JRuby would work using a non-Java app server, would it?)

In the past I've tried to utilize Rubinius's threading capabilities using other Ruby App servers like Rainbows using the ThreadPool/Spawn strategy, but without success. The processes kept hanging or time out and I'm not sure how or why that happened. I eventually gave up on it. Someone then later pointed out that what we need a new app server that was built for concurrency/threading from the ground up because existing solutions weren't really capable enough. Today I see Puma and I'm wondering: "Is this it?" :)

Java thread exception with concurrent requests

I'm trying to test out concurrent requests w/puma. I can successfully call each of the routes below individually. When I try to call the long one, then the short while the long is executing, one of two things seem to happen:

  1. The short one never returns
  2. The short one returns, then the long one (as I'd expect), but then I get a Java exception.

Code & exception below:

Ruby (w/RVM):

jruby 1.6.5 (ruby-1.9.2-p136) (2011-10-25 9dcd388) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [darwin-x86_64-java]

Gemfile:

gem 'rack'
gem 'jruby-rack'
gem 'puma'
gem 'sinatra'
gem 'jdbc-mysql'
gem 'sequel'

config.ru:

require 'tester'
Tester.run!

tester.rb:

require 'sinatra/base'
require 'sequel'

class Tester < Sinatra::Base
  set :server, :puma

  get '/short' do
    db = Sequel.connect("jdbc:mysql://localhost/test?user=root")    
    db.run "select sleep(1)"
    "Hello!"
 end

  get '/long' do
    db = Sequel.connect("jdbc:mysql://localhost/test?user=root")
    db.run "select sleep(20)"
    "Long Hello!"
  end

end

Exception:

Exception in thread "RubyThread-5: /Users/bporterfield/.rvm/gems/jruby-1.6.5@2j/gems/puma-0.9.2-java/lib/puma/thread_pool.rb:49" java.nio.channels.IllegalBlockingModeException

Full rackup to stacktrace here: http://pastebin.com/PZ22bhx2

Code Reloading

A small code review led me to one interesting feature of the Puma control server: the /reload action.

When I've set up Puma with the following command:

% bundle exec puma --control 'tcp://127.0.0.1:1337' --control-token 'foo'
Puma 1.1.1 starting...
* Min threads: 0, max threads: 16
* Listening on tcp://0.0.0.0:9292
* Starting status server on tcp://127.0.0.1:1337
Use Ctrl-C to stop

and executed the following command:

% curl 'http://127.0.0.1:1337/restart?token=foo'

I got no output from curl among with the following strange output from Puma process:

* Restarting...
Puma 1.1.1 starting...
* Min threads: 0, max threads: 16
* Listening on tcp://0.0.0.0:9292
* Starting status server on tcp://127.0.0.1:1337
Address already in use - bind(2)

The Puma process was terminated. Is this bug or feature?

Build error with JRuby 1.6.7 and XCode 4.3

$ jgem install puma
Building native extensions.  This could take a while...
ERROR:  Error installing puma:
    ERROR: Failed to build gem native extension.

        /Users/carl/.rvm/rubies/jruby-1.6.7/bin/jruby extconf.rb
WARNING: JRuby does not support native extensions or the `mkmf' library very well.
Check http://kenai.com/projects/jruby/pages/Home for alternatives.
creating Makefile

make
cc -I. -I/Users/carl/.rvm/rubies/jruby-1.6.7/lib/native/include -I/Users/carl/.rvm/rubies/jruby-1.6.7/lib/native/include/ruby -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE      -fPIC -DTARGET_RT_MAC_CFM=0  -fno-omit-frame-pointer -fno-strict-aliasing  -fexceptions    -arch i386 -c http11_parser.c
cc -I. -I/Users/carl/.rvm/rubies/jruby-1.6.7/lib/native/include -I/Users/carl/.rvm/rubies/jruby-1.6.7/lib/native/include/ruby -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE      -fPIC -DTARGET_RT_MAC_CFM=0  -fno-omit-frame-pointer -fno-strict-aliasing  -fexceptions    -arch i386 -c puma_http11.c
cc -dynamic -bundle -undefined dynamic_lookup  -o puma_http11.bundle http11_parser.o puma_http11.o -L"." -L"/Users/carl/.rvm/rubies/jruby-1.6.7/lib" -bundle -framework JavaVM -Wl,-syslibroot, -mmacosx-version-min=10.5   -arch i386  
ld: library not found for -lbundle1.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [puma_http11.bundle] Error 1


Gem files will remain installed in /Users/carl/.rvm/gems/jruby-1.6.7/gems/puma-1.0.0 for inspection.
Results logged to /Users/carl/.rvm/gems/jruby-1.6.7/gems/puma-1.0.0/ext/puma_http11/gem_make.out

uninitialized constant Rubinius::FROM_AGENT (NameError)

I've tried 0.9.3, 0.9.2 and 0.9.0 releases of the Puma gem on Rubinius in the hope that I could get around this. All requests to the app immediately make Puma die.

$ rails s puma
=> Booting Puma
=> Rails 3.2.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Puma 0.9.2 starting...
* Min threads: 0, max threads: 16
* Listening on tcp://0.0.0.0:3000
Exiting
An exception occurred running script/rails
    uninitialized constant Rubinius::FROM_AGENT (NameError)

User defined backtrace:

Backtrace:
  ActiveSupport::Dependencies(Module)#load_missing_constant at \
          /Users/mathiasx/Developer/.rvm/gems/rbx-head@peculiarity/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:520
  { } in ActiveSupport::Dependencies::ModuleConstMissing(Module)#const_missing at \
          /Users/mathiasx/Developer/.rvm/gems/rbx-head@peculiarity/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:192
                            Array#each at kernel/bootstrap/array.rb:68
  ActiveSupport::Dependencies::ModuleConstMissing(Module)#const_missing at \
          /Users/mathiasx/Developer/.rvm/gems/rbx-head@peculiarity/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:190
  { } in Rubinius::AgentRegistry.spawn_thread at kernel/delta/agent.rb:52
                        Thread#__run__ at kernel/bootstrap/thread.rb:146

Here's my RVM info:

$ rvm info

rbx-head@peculiarity:

  system:
    uname:       "Darwin banshee.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386"
    bash:        "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
    zsh:         "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"

  rvm:
    version:      "rvm 1.10.2 by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.beginrescueend.com/]"
    updated:      "21 hours 54 minutes 21 seconds ago"

  ruby:
    interpreter:  "rubinius"
    version:      "2.0.0dev"
    date:         "rubinius 2.0.0dev (1.8.7 70773724 yyyy-mm-dd JI) [x86_64-apple-darwin10.8.0]"
    platform:     "x86_64-apple-darwin10.8.0"
    patchlevel:   "1.8.7 70773724 yyyy-mm-dd JI"
    full_version: "rubinius 2.0.0dev (1.8.7 70773724 yyyy-mm-dd JI) [x86_64-apple-darwin10.8.0]"

  homes:
    gem:          "/Users/mathiasx/Developer/.rvm/gems/rbx-head@peculiarity"
    ruby:         "/Users/mathiasx/Developer/.rvm/rubies/rbx-head"

  binaries:
    ruby:         "/Users/mathiasx/Developer/.rvm/rubies/rbx-head/bin/ruby"
    irb:          "/Users/mathiasx/Developer/.rvm/rubies/rbx-head/bin/irb"
    gem:          "/Users/mathiasx/Developer/.rvm/rubies/rbx-head/bin/gem"
    rake:         "/Users/mathiasx/Developer/.rvm/gems/rbx-head@global/bin/rake"

  environment:
    PATH:         "/Users/mathiasx/Developer/.rvm/gems/rbx-head@peculiarity/bin:/Users/mathiasx/Developer/.rvm/gems/rbx-head@global/bin:/Users/mathiasx/Developer/.rvm/rubies/rbx-head/bin:/Users/mathiasx/Developer/.rvm/bin:/Users/mathiasx/Developer/share/python:/Users/mathiasx/Developer/share/npm/bin:/Users/mathiasx/Developer/Cellar/python/2.7/bin:/Users/mathiasx/Developer/bin:/Users/mathiasx/Developer/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/local/MacGPG2/bin:/usr/X11/bin"
    GEM_HOME:     "/Users/mathiasx/Developer/.rvm/gems/rbx-head@peculiarity"
    GEM_PATH:     "/Users/mathiasx/Developer/.rvm/gems/rbx-head@peculiarity:/Users/mathiasx/Developer/.rvm/gems/rbx-head@global"
    MY_RUBY_HOME: "/Users/mathiasx/Developer/.rvm/rubies/rbx-head"
    IRBRC:        "/Users/mathiasx/Developer/.rvm/rubies/rbx-head/.irbrc"
    RUBYOPT:      ""
    gemset:       "peculiarity"

Socket 'already in use'

If there is a socket present, the server fails to start:

bundle exec puma -b unix:///var/run/website.sock
Puma 0.9.5 starting...
* Min threads: 0, max threads: 16
* Listening on unix:///var/run/website.sock
Address already in use - /var/run/website.sock

My first thought was to have Puma remove this socket file before it quits, but I'm not sure what the best-practices for UNIX socket file management are so I wanted to file a ticket before sending any pull requests so the bearded unix wizards could chime in.

This is being connected to an nginx proxy, so it's possible that nginx is holding this file open and that's what's causing the problem.

Rack::Request.scheme should return https if running SSLServer

Appears as though 5abf158 makes Rack::Request.scheme return http in some cases when running sslserver.

To test - config.ru:

class Test
  def call(env)
    request = Rack::Request.new(env)
    return [200, {}, ["#{request.scheme}"]]
  end
end
run Test.new

Starting with: puma -b tcp://127.0.0.1:3000 config.ru and hitting http://localhost:3000 returns http.

Starting with

puma -b 'ssl://127.0.0.1:3000?key=puma/puma_keypair.pem&cert=puma/cert_puma.pem' config.ru

and hitting https://localhost:3000 still returns http.

Thanks!

Loading Incorrect Images

Images (notably css background images) are entirely incorrect, showing a different image. This hasn't surfaced in Webrick or Unicorn. I've seen it a few times in development, but it happens consistently in staging. Taking a look in the inspector and in logs the urls appear to be correct, but there is no mistaking that the image itself is mixed up—the logo being replaced with a background tile, for example.

Verified in Chrome, Safari, and Firefox (hard reload in each of them). The interchanged images aren't the same across browsers, but the effect is present in all of them.

Here is the basic stack, ff there is any additional info I can provide let me know.

Ruby 1.9.3-p125, Rails 3.2.2, Puma with default of 0-16 threads.

Odd error on shutdown on JRuby

I'm seeing a peculiar error on shutdown in JRuby:

system /tmp/app $ puma config.ru 
Puma 0.9.3 starting...
* Min threads: 0, max threads: 16
* Listening on tcp://0.0.0.0:4567
== Sinatra/1.3.2 has taken the stage on 4567 for development with backup from Puma
^C
== Sinatra has ended his set (crowd applauds)
missing run or map statement

Investigating.

"cannot load such file -- rack/handler/puma" unless launching Puma directly

Platform info:

$ uname -a
Linux roamer 3.3.1-1-ARCH #1 SMP PREEMPT Tue Apr 3 06:46:17 UTC 2012 x86_64 Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz GenuineIntel GNU/Linux
$ ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]
$ rails -v
Rails 3.2.3
$ puma -v
puma: version unknown

(The Puma version is the current most recent, 1.2.1)

Server launch attempts:

trevor@roamer:~/projects/brainbox (ruby-1.9.3-p125@brainbox) (master)
$ puma
Puma 1.2.1 starting...
* Min threads: 0, max threads: 16
* Listening on tcp://0.0.0.0:9292
Use Ctrl-C to stop
127.0.0.1 - - [13/Apr/2012 11:10:27] "GET %2Findex.html HTTP/1.1" 304 - 0.3744
127.0.0.1 - - [13/Apr/2012 11:10:27] "GET /rails.png HTTP/1.1" 304 - 0.3463
127.0.0.1 - - [13/Apr/2012 11:10:27] "GET %2Ffavicon.ico HTTP/1.1" 304 - 0.0009
127.0.0.1 - - [13/Apr/2012 11:10:29] "GET /rails/info/properties HTTP/1.1" 200 - 0.0723
^C - Gracefully stopping, waiting for requests to finish
 - Goodbye!
trevor@roamer:~/projects/brainbox (ruby-1.9.3-p125@brainbox) (master)
$ puma config.ru
Puma 1.2.1 starting...
* Min threads: 0, max threads: 16
* Listening on tcp://0.0.0.0:9292
Use Ctrl-C to stop
127.0.0.1 - - [13/Apr/2012 10:59:11] "GET %2Findex.html HTTP/1.1" 200 5906 0.4748
127.0.0.1 - - [13/Apr/2012 10:59:11] "GET /rails.png HTTP/1.1" 200 6646 0.3122
127.0.0.1 - - [13/Apr/2012 10:59:11] "GET %2Ffavicon.ico HTTP/1.1" 200 - 0.0011
127.0.0.1 - - [13/Apr/2012 10:59:14] "GET /rails/info/properties HTTP/1.1" 200 - 0.0755
^C - Gracefully stopping, waiting for requests to finish
 - Goodbye!
trevor@roamer:~/projects/brainbox (ruby-1.9.3-p125@brainbox) (master)
$ rails s puma
Exiting
/home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/rack-1.4.1/lib/rack/handler.rb:63:in `require': cannot load such file -- rack/handler/puma (LoadError)
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/rack-1.4.1/lib/rack/handler.rb:63:in `try_require'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/rack-1.4.1/lib/rack/handler.rb:16:in `get'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/rack-1.4.1/lib/rack/server.rb:269:in `server'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/railties-3.2.3/lib/rails/commands/server.rb:59:in `start'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/railties-3.2.3/lib/rails/commands.rb:55:in `block in <top (required)>'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/railties-3.2.3/lib/rails/commands.rb:50:in `tap'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/railties-3.2.3/lib/rails/commands.rb:50:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'
trevor@roamer:~/projects/brainbox (ruby-1.9.3-p125@brainbox) (master)
$ rackup -s puma
/home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- rack/handler/puma (LoadError)
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/rack-1.4.1/lib/rack/handler.rb:63:in `try_require'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/rack-1.4.1/lib/rack/handler.rb:16:in `get'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/rack-1.4.1/lib/rack/server.rb:269:in `server'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/rack-1.4.1/lib/rack/server.rb:208:in `block in logging_middleware'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/rack-1.4.1/lib/rack/server.rb:292:in `call'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/rack-1.4.1/lib/rack/server.rb:292:in `block in build_app'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/rack-1.4.1/lib/rack/server.rb:291:in `reverse_each'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/rack-1.4.1/lib/rack/server.rb:291:in `build_app'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/rack-1.4.1/lib/rack/server.rb:137:in `start'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/gems/rack-1.4.1/bin/rackup:4:in `<top (required)>'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/bin/rackup:19:in `load'
        from /home/trevor/.rvm/gems/ruby-1.9.3-p125@brainbox/bin/rackup:19:in `<main>'

Won't work with Rails 3.0.x because of Rack 1.2.x bug

Problem

  1. If you use Rails 3.0.12, you are stuck with Rack 1.2.5
  2. Rack 1.2.5 blows up if env['CONTENT_TYPE'] == "" and you call Rack::Request#media_type (or any other method that calls it, such as the very common pattern Rack::Request.new(env).params) per a bug that was fixed in later versions
  3. At the same time, Rack::Lint complains if you set env['CONTENT_TYPE'] to nil.

Possible solution

I think unicorn (accidentially? intentionally?) solves this by defaulting to text/html... but I could be wrong:

# https://github.com/defunkt/unicorn/blob/master/lib/unicorn/cgi_wrapper.rb#L95
@head[CONTENT_TYPE] ||= "text/html"

So puma could default to text/html (?).

error on request in jruby. java extension doesn't compile with bundler & jruby?

I've been toying with this for a while and can't work out what I may be doing wrong. Perhaps some local java / rvm / bundler setting. At any rate, if I use bundler to install puma from github, it doesn't appear as though the java version of the parser is compiled. I often get the following when I make a request:

java(6924,0x1159b6000) malloc: *** error for object 0x7faba290d340: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

If I clone the gem locally, rake compile (using jruby) and point bundler at the path, I do not get the error. So, this Gemfile results in everything working:

gem 'puma', :path => "~/dev/puma"

While this one does not:

gem 'puma', :git => 'https://github.com/evanphx/puma.git'

I can also confirm that, in the bundled gem from github, there is no jar in the lib/puma/ folder. When I rake:compile locally, I do see a puma_http11.jar in the lib/puma folder.

I may not be doing something right - perhaps this is just a problem with my local settings? Thanks!

Add -p and --port flag

It would be useful if puma supported the -p and --port flags like the rackup command so it can be run on any port.

wrong number of arguments (4 for 3)

Getting this when shutting down:

Puma 1.1.1 starting...
* Min threads: 0, max threads: 16
* Listening on tcp://0.0.0.0:5000
Use Ctrl-C to stop
127.0.0.1 - - [31/Mar/2012 10:32:10] "GET /about/api HTTP/1.1" 200 ["44311"] 1.2284
^C - Gracefully stopping, waiting for requests to finish
wrong number of arguments (4 for 3)

Rails 3.1.3 - JRuby 1.6.5.1 - Sun Java 7: Does Not Respond To Requests

Hello,

I started a brand new app today and I wanted to try Puma out with JRuby but unfortunately I was unable to get it to respond to requests. Here is some info:

  • jruby 1.6.5.1 (ruby-1.8.7-p330) (2011-12-27 1bf37c2) (Java HotSpot(TM) 64-Bit Server VM 1.7.0) [linux-amd64-java]

  • Rails 3.1.3

  • puma 0.9.3

  • Rack 1.3.6

    I created a brand new application added puma to my GemFile and when I run the following command it starts up but when I try to hit the site from the browser nothing happens and it just sits there.

~/temp/test_app$ rails s puma
=> Booting Puma
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Puma 0.9.3 starting...

  • Min threads: 0, max threads: 16
  • Listening on tcp://0.0.0.0:3000

I also tried just running puma without the rails call and same issue. I'm not sure if there are any logs that I can help with but let me know.

JRuby 1.6.6 + Rails 3.2.1 | Lots of errors?

Using JRuby 1.6.6, Rails 3.2.1

Running: bundle exec puma -b tcp://0.0.0.0:3000

On a bare Rails 3.2.1 app, on the basic Rails index.html with the rails.png image, when you hold CMD+R and spam refresh on the browser, eventually within about 10 seconds the following exception will be raised:

java(9162,0x10f01e000) malloc: *** error for object 0x7f9739c22bb0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

Also occasionally see this:

Exception in thread "RubyThread-9: /Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/thread_pool.rb:55" java.nio.channels.IllegalBlockingModeException
    at java.nio.channels.spi.AbstractSelectableChannel.configureBlocking(AbstractSelectableChannel.java:257)
    at org.jruby.util.io.SelectBlob.tidyUp(SelectBlob.java:335)
    at org.jruby.util.io.SelectBlob.goForIt(SelectBlob.java:86)
    at org.jruby.RubyIO.select_static(RubyIO.java:3351)
    at org.jruby.RubyIO.select(RubyIO.java:3347)
    at org.jruby.RubyIO$s$0$3$select.call(RubyIO$s$0$3$select.gen:65535)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:69)
    at org.jruby.ast.CallManyArgsNode.interpret(CallManyArgsNode.java:59)
    at org.jruby.ast.LocalAsgnNode.interpret(LocalAsgnNode.java:123)
    at org.jruby.ast.IfNode.interpret(IfNode.java:111)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.ast.IfNode.interpret(IfNode.java:119)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.ast.IfNode.interpret(IfNode.java:117)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.ast.WhileNode.interpret(WhileNode.java:131)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.ast.WhileNode.interpret(WhileNode.java:131)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
    at org.jruby.ast.RescueNode.executeBody(RescueNode.java:216)
    at org.jruby.ast.RescueNode.interpretWithJavaExceptions(RescueNode.java:120)
    at org.jruby.ast.RescueNode.interpret(RescueNode.java:110)
    at org.jruby.ast.EnsureNode.interpret(EnsureNode.java:96)
    at org.jruby.ast.BeginNode.interpret(BeginNode.java:83)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75)
    at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:190)
    at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:199)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:312)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:169)
    at org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:36)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
    at org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
    at org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:212)
    at org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:200)
    at org.jruby.runtime.Interpreted19Block.call(Interpreted19Block.java:131)
    at org.jruby.runtime.Block.call(Block.java:89)
    at org.jruby.RubyProc.call(RubyProc.java:270)
    at org.jruby.RubyProc.call19(RubyProc.java:258)
    at org.jruby.RubyProc$i$0$0$call19.call(RubyProc$i$0$0$call19.gen:65535)
    at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:211)
    at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:207)
    at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:312)
    at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:169)
    at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.ast.WhileNode.interpret(WhileNode.java:131)
    at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:104)
    at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
    at org.jruby.evaluator.ASTInterpreter.INTERPRET_BLOCK(ASTInterpreter.java:112)
    at org.jruby.runtime.Interpreted19Block.evalBlockBody(Interpreted19Block.java:212)0:0:0:0:0:0:0:1%0 - - [10/Feb/
    at org.jruby.runtime.Interpreted19Block.yield(Interpreted19Block.java:200)
2012 18:14:20] "GET /index.html HTTP/1.1" 304 - 0.0120
    at org.jruby.runtime.Interpreted19Block.call(Interpreted19Block.java:131)
    at org.jruby.runtime.Block.call(Block.java:89)
    at org.jruby.RubyProc.call(RubyProc.java:270)
    at org.jruby.RubyProc.call(RubyProc.java:224)
    at org.jruby.internal.runtime.RubyRunnable.run(RubyRunnable.java:95)
    at java.lang.Thread.run(Thread.java:680)

Another thing I noticed is when running Puma through Bundler, two processes seem to stay running. Is this normal? What is the other process doing? One is using about 200mb ram, the other is using 130mb ram. When running Puma without using Bundler I get this:

/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:6 warning: already initialized constant HTTP_STATUS_CODES
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:47 warning: already initialized constant STATUS_WITH_NO_ENTITY_BODY
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:66 warning: already initialized constant PERSISTENT_TIMEOUT
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:68 warning: already initialized constant DATE
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:70 warning: already initialized constant SCRIPT_NAME
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:73 warning: already initialized constant REQUEST_URI
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:74 warning: already initialized constant REQUEST_PATH
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:76 warning: already initialized constant PATH_INFO
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:78 warning: already initialized constant VERSION
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:78 warning: already initialized constant PUMA_VERSION
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:80 warning: already initialized constant PUMA_TMP_BASE
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:83 warning: already initialized constant ERROR_404_RESPONSE
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:85 warning: already initialized constant CONTENT_LENGTH
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:88 warning: already initialized constant ERROR_503_RESPONSE
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:91 warning: already initialized constant CHUNK_SIZE
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:95 warning: already initialized constant MAX_HEADER
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:98 warning: already initialized constant MAX_BODY
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:101 warning: already initialized constant STATUS_FORMAT
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:103 warning: already initialized constant CONTENT_TYPE
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:105 warning: already initialized constant LAST_MODIFIED
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:106 warning: already initialized constant ETAG
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:107 warning: already initialized constant SLASH
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:108 warning: already initialized constant REQUEST_METHOD
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:109 warning: already initialized constant GET
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:110 warning: already initialized constant HEAD
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:112 warning: already initialized constant ETAG_FORMAT
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:113 warning: already initialized constant LINE_END
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:114 warning: already initialized constant REMOTE_ADDR
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:115 warning: already initialized constant HTTP_X_FORWARDED_FOR
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:116 warning: already initialized constant HTTP_IF_MODIFIED_SINCE
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:117 warning: already initialized constant HTTP_IF_NONE_MATCH
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:118 warning: already initialized constant REDIRECT
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:119 warning: already initialized constant HOST
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:121 warning: already initialized constant SERVER_NAME
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:122 warning: already initialized constant SERVER_PORT
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:123 warning: already initialized constant HTTP_HOST
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:124 warning: already initialized constant PORT_80
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:126 warning: already initialized constant SERVER_PROTOCOL
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:127 warning: already initialized constant HTTP_11
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:128 warning: already initialized constant HTTP_10
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:130 warning: already initialized constant SERVER_SOFTWARE
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:131 warning: already initialized constant GATEWAY_INTERFACE
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:132 warning: already initialized constant CGI_VER
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:134 warning: already initialized constant STOP_COMMAND
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:135 warning: already initialized constant HALT_COMMAND
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:137 warning: already initialized constant RACK_INPUT
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:138 warning: already initialized constant RACK_URL_SCHEME
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:139 warning: already initialized constant RACK_AFTER_REPLY
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:141 warning: already initialized constant HTTP
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:142 warning: already initialized constant HTTPS
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:144 warning: already initialized constant HTTPS_KEY
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:146 warning: already initialized constant HTTP_VERSION
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:147 warning: already initialized constant HTTP_CONNECTION
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:149 warning: already initialized constant HTTP_11_200
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:150 warning: already initialized constant HTTP_10_200
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:152 warning: already initialized constant CLOSE
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:153 warning: already initialized constant KEEP_ALIVE
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:155 warning: already initialized constant CONTENT_LENGTH2
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:156 warning: already initialized constant CONTENT_LENGTH_S
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:157 warning: already initialized constant TRANSFER_ENCODING
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:159 warning: already initialized constant CONNECTION_CLOSE
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:160 warning: already initialized constant CONNECTION_KEEP_ALIVE
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:162 warning: already initialized constant TRANSFER_ENCODING_CHUNKED
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:163 warning: already initialized constant CLOSE_CHUNKED
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:165 warning: already initialized constant COLON
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/const.rb:167 warning: already initialized constant NEWLINE
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/events.rb:45 warning: already initialized constant DEFAULT
/Users/Michael/.rvm/gems/jruby-1.6.6/bundler/gems/puma-256970e0487b/lib/puma/server.rb:324 warning: already initialized constant EmptyBody
LoadError: no such file to load -- openssl/digest
        require at org/jruby/RubyKernel.java:1036
         (root) at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/net-ssh-2.3.0/lib/net/ssh/transport/hmac/abstract.rb:2
        require at org/jruby/RubyKernel.java:1036
         (root) at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/net-ssh-2.3.0/lib/net/ssh/transport/hmac/abstract.rb:1
        require at org/jruby/RubyKernel.java:1036
         (root) at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/net-ssh-2.3.0/lib/net/ssh/transport/hmac/md5.rb:2
        require at org/jruby/RubyKernel.java:1036
         (root) at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/net-ssh-2.3.0/lib/net/ssh/transport/hmac.rb:6
        require at org/jruby/RubyKernel.java:1036
         (root) at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/net-ssh-2.3.0/lib/net/ssh/transport/algorithms.rb:7
        require at org/jruby/RubyKernel.java:1036
         (root) at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/net-ssh-2.3.0/lib/net/ssh/transport/session.rb:10
        require at org/jruby/RubyKernel.java:1036
         (root) at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/net-ssh-2.3.0/lib/net/ssh.rb:2
        require at org/jruby/RubyKernel.java:1036
         (root) at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/net-ssh-gateway-1.1.0/lib/net/ssh/gateway.rb:2
        require at org/jruby/RubyKernel.java:1036
         (root) at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/capistrano-2.9.0/lib/capistrano/configuration/connections.rb:4
        require at org/jruby/RubyKernel.java:1036
         (root) at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/capistrano-2.9.0/lib/capistrano/configuration.rb:1
        require at org/jruby/RubyKernel.java:1036
        require at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/capistrano-2.9.0/lib/capistrano.rb:68
           each at org/jruby/RubyArray.java:1614
        require at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/bundler-1.0.21/lib/bundler/runtime.rb:66
           each at org/jruby/RubyArray.java:1614
        require at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/bundler-1.0.21/lib/bundler/runtime.rb:55
        require at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/bundler-1.0.21/lib/bundler.rb:122
         (root) at /Users/Michael/Desktop/hirefire-2/config/application.rb:13
        require at org/jruby/RubyKernel.java:1036
        require at /Users/Michael/.rvm/rubies/jruby-1.6.6/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36
         (root) at /Users/Michael/Desktop/hirefire-2/config/application.rb:2
        require at org/jruby/RubyKernel.java:1036
        require at /Users/Michael/.rvm/rubies/jruby-1.6.6/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36
     parse_file at /Users/Michael/Desktop/hirefire-2/config/environment.rb:4
  instance_eval at org/jruby/RubyBasicObject.java:1726
     initialize at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/rack-1.4.1/lib/rack/builder.rb:51
     parse_file at config.ru:1
           eval at org/jruby/RubyKernel.java:1082
     parse_file at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/rack-1.4.1/lib/rack/builder.rb:40
            app at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/puma-0.9.3-java/lib/puma/configuration.rb:56
            run at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/puma-0.9.3-java/lib/puma/cli.rb:215
         (root) at /Users/Michael/.rvm/gems/jruby-1.6.6/gems/puma-0.9.3-java/bin/puma:11
           load at org/jruby/RubyKernel.java:1062
         (root) at /Users/Michael/.rvm/gems/jruby-1.6.6/bin/puma:19

Trimming in thread pool can result in requests hanging

With default AutoTrim settings, there is potential for requests to get stuck waiting on an available worker:

  1. A long-running request is made, adding work to Queue and spawning a worker thread. There are now more than min workers alive.
  2. The autotrim thread wakes up and, seeing threads that could be trimmed, adds a Trim to the Queue.
  3. Second request is made while the first request is still working. New worker thread is spawned because there are no threads waiting on the Queue. Work is added to Queue.
  4. Newly spawned worker thread pops Trim off of Queue, and promptly kills itself
  5. Second request is still in Queue, but there is only 1 worker thread now, and it's still busy with the first request. Second request now hangs until first request completes (or another request comes in, spawning new thread).

all Sinatra routes are accessed twice

Starting the samle Sinatra app

# myapp.rb
require 'sinatra'

get '/' do
  'Hello world!'
end

will result in this:

% ruby sinatra.rb -s puma                                                                                                                    
Puma 0.9.1 starting...
* Min threads: 0, max threads: 16
* Listening on tcp://0.0.0.0:4567
== Sinatra/1.3.1 has taken the stage on 4567 for development with backup from Puma
127.0.0.1 - - [13/Dec/2011 17:55:19] "GET / HTTP/1.1" 200 12 0.0045
127.0.0.1 - - [13/Dec/2011 17:55:19] "GET / HTTP/1.1" 200 12 0.1636
127.0.0.1 - - [13/Dec/2011 17:55:20] "GET /favicon.ico HTTP/1.1" 404 447 0.0028
127.0.0.1 - - [13/Dec/2011 17:55:20] "GET /favicon.ico HTTP/1.1" 404 447 0.0030

Provide an option to daemonize and better restart

I'm trying to integrate puma in a capistrano recipe, however puma does not offer, afaik, ways to daemonize the process.

When using nohup and stdout/stderr redirection in capistrano during a run command, depending on the pty setting the process may not start on the remote server.

Also using "cd #{current_path} && bundle exec pumactl -S /tmp/puma.state restart" pumactl assumes that the file exists, otherwise it will throw an error.

In capistrano this can be solved by :on_error => :continue on the directive, however I think that puma should try to restart in some way after it failed to find the puma.state file. Perhaps it can follow the thin example and accept again a -C flag.

Otherwise we can just issue stop and/or leave the job to monit or similar but losing the unicorn-like restart feature.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.