Re: [PATCH] construct listener_fds Hash in 1.8 compatible way

2013-11-01 Thread Ernest W. Durbin III
On Fri, Nov 1, 2013 at 12:50 PM, Eric Wong normalper...@yhbt.net wrote:
 Ernest W. Durbin III ewdur...@gmail.com wrote:
 This renables the ability for Ruby 1.8 environments to perform reexecs

 Is this for Ruby 1.8.6?  I've only tested on 1.8.7,
 I haven't had a 1.8.6 installation in a while.


I'll admit that the reason I need it is for a Ruby 1.8.6 environment...

However, Ruby 1.8.7 does not have support for that Hash constructor
either it simply fails silently and in a bug prone manner.

```
[ernestd@ewd3do ~]$ ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-linux]
[ernestd@ewd3do ~]$ irb
irb(main):001:0 thing = Hash[ [ 'foo', 'bar' ], ['fizz', 'buzz'] ]
= {[foo, bar]=[fizz, buzz]}
irb(main):002:0 thing = Hash[ [ 'foo', 'bar' ] ]
= {}
```

```
-bash-4.1$ ruby --version
ruby 1.8.6 (2010-09-02 patchlevel 420) [x86_64-linux]
-bash-4.1$ irb
irb(main):001:0 thing = Hash[ [ 'foo', 'bar' ], ['fizz', 'buzz'] ]
= {[foo, bar]=[fizz, buzz]}
irb(main):002:0 thing = Hash[ [ 'foo', 'bar' ] ]
ArgumentError: odd number of arguments for Hash
from (irb):2:in `[]'
from (irb):2
from :0
```


 --- a/lib/unicorn/http_server.rb
 +++ b/lib/unicorn/http_server.rb
 @@ -449,13 +449,14 @@ class Unicorn::HttpServer
  end

  self.reexec_pid = fork do
 -  listener_fds = Hash[LISTENERS.map do |sock|
 +  listener_fds = Hash.new

  listener_fds = {}

 is generally preferred unless there's a default value.

 I'll apply the edited change if that's alright with you (and update
 the commit message for 1.8.6 support).

It's up to you how to get this merged :) Whatever is easiest.


 Thanks!
 ___
 Unicorn mailing list - mongrel-unicorn@rubyforge.org
 http://rubyforge.org/mailman/listinfo/mongrel-unicorn
 Do not quote signatures (like this one) or top post when replying
___
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying


Re: [PATCH] construct listener_fds Hash in 1.8 compatible way

2013-11-01 Thread Eric Wong
Ernest W. Durbin III ewdur...@gmail.com wrote:
 On Fri, Nov 1, 2013 at 12:50 PM, Eric Wong normalper...@yhbt.net wrote:
  Ernest W. Durbin III ewdur...@gmail.com wrote:
  This renables the ability for Ruby 1.8 environments to perform reexecs
 
  Is this for Ruby 1.8.6?  I've only tested on 1.8.7,
  I haven't had a 1.8.6 installation in a while.
 
 
 I'll admit that the reason I need it is for a Ruby 1.8.6 environment...

OK (wow!).   I've been pondering dropping 1.8 entirely, but I think I'll
keep it for now since CentOS 6.x still uses it

Anyways, was that the only 1.8.6-incompatible thing we did?

 However, Ruby 1.8.7 does not have support for that Hash constructor
 either it simply fails silently and in a bug prone manner.
 
 ```
 [ernestd@ewd3do ~]$ ruby --version
 ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-linux]
 [ernestd@ewd3do ~]$ irb
 irb(main):001:0 thing = Hash[ [ 'foo', 'bar' ], ['fizz', 'buzz'] ]
 = {[foo, bar]=[fizz, buzz]}

Actually, on 1.8.7, unicorn does the following (note the extra outer array)

irb(main):001:0 thing = Hash[ [ [ 'foo', 'bar' ], ['fizz', 'buzz'] ] ]
= {fizz=buzz, foo=bar}

so it was fine
___
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying


Re: [PATCH] construct listener_fds Hash in 1.8 compatible way

2013-11-01 Thread Ernest W. Durbin III
On Fri, Nov 1, 2013 at 2:54 PM, Eric Wong normalper...@yhbt.net wrote:
 Ernest W. Durbin III ewdur...@gmail.com wrote:
 On Fri, Nov 1, 2013 at 12:50 PM, Eric Wong normalper...@yhbt.net wrote:
  Ernest W. Durbin III ewdur...@gmail.com wrote:
  This renables the ability for Ruby 1.8 environments to perform reexecs
 
  Is this for Ruby 1.8.6?  I've only tested on 1.8.7,
  I haven't had a 1.8.6 installation in a while.
 

 I'll admit that the reason I need it is for a Ruby 1.8.6 environment...

 OK (wow!).   I've been pondering dropping 1.8 entirely, but I think I'll
 keep it for now since CentOS 6.x still uses it

 Anyways, was that the only 1.8.6-incompatible thing we did?

That's all I've found so far! Happy to be dropping thin, and I promise
we're on course to get past 1.8.6 at some point... But I'm just the
Ops guy :)


 However, Ruby 1.8.7 does not have support for that Hash constructor
 either it simply fails silently and in a bug prone manner.

 ```
 [ernestd@ewd3do ~]$ ruby --version
 ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-linux]
 [ernestd@ewd3do ~]$ irb
 irb(main):001:0 thing = Hash[ [ 'foo', 'bar' ], ['fizz', 'buzz'] ]
 = {[foo, bar]=[fizz, buzz]}

 Actually, on 1.8.7, unicorn does the following (note the extra outer array)

 irb(main):001:0 thing = Hash[ [ [ 'foo', 'bar' ], ['fizz', 'buzz'] ] ]
 = {fizz=buzz, foo=bar}

 so it was fine

Interesting. Sorry I missed that in the initial irb tests.

Funnily enough, the List of List's Constructor type isn't documented for 1.8.7

Thanks Again!

 ___
 Unicorn mailing list - mongrel-unicorn@rubyforge.org
 http://rubyforge.org/mailman/listinfo/mongrel-unicorn
 Do not quote signatures (like this one) or top post when replying
___
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying


Re: [ISSUE] Unicorn appears to be leaking TCP sockets

2013-11-01 Thread Eric Wong
Ernest W. Durbin III ewdur...@gmail.com wrote:
 Gist containing configs and logs:
 https://gist.github.com/ewdurbin/1d9d2ea14a4231a5e7cc

I was stumped until I saw your command-line:

  -p, /var/run/marketing-staging/unicorn.pid

PID file path is '-P' (but we recommend using the config file for that)

Pushing out the following:
8
Subject: [PATCH] bin/*: enforce -p/--port argument to be a valid integer

Users may confuse '-p' with the (to-be-deprecated) '-P/--pid'
option, leading to surprising behavior if a pathname is passed as a
port, because String#to_i would convert it to zero, causing:

TCPServer.new(host, port = 0)

to bind to a random, unused port.
---
 bin/unicorn   | 6 +++---
 bin/unicorn_rails | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/bin/unicorn b/bin/unicorn
index 01984f8..c272e43 100755
--- a/bin/unicorn
+++ b/bin/unicorn
@@ -47,9 +47,9 @@ op = OptionParser.new(, 24, '  ') do |opts|
 rackup_opts[:set_listener] = true
   end
 
-  opts.on(-p, --port PORT,
-  use PORT (default: #{Unicorn::Const::DEFAULT_PORT})) do |p|
-rackup_opts[:port] = p.to_i
+  opts.on(-p, --port PORT, Integer,
+  use PORT (default: #{Unicorn::Const::DEFAULT_PORT})) do |port|
+rackup_opts[:port] = port
 rackup_opts[:set_listener] = true
   end
 
diff --git a/bin/unicorn_rails b/bin/unicorn_rails
index 4bd599f..b080846 100755
--- a/bin/unicorn_rails
+++ b/bin/unicorn_rails
@@ -48,9 +48,9 @@ op = OptionParser.new(, 24, '  ') do |opts|
 rackup_opts[:set_listener] = true
   end
 
-  opts.on(-p, --port PORT,
-  use PORT (default: #{Unicorn::Const::DEFAULT_PORT})) do |p|
-rackup_opts[:port] = p.to_i
+  opts.on(-p, --port PORT, Integer,
+  use PORT (default: #{Unicorn::Const::DEFAULT_PORT})) do |port|
+rackup_opts[:port] = port
 rackup_opts[:set_listener] = true
   end
 
___
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying


Re: [ISSUE] Unicorn appears to be leaking TCP sockets

2013-11-01 Thread Ernest W. Durbin III
On Fri, Nov 1, 2013 at 4:07 PM, Eric Wong normalper...@yhbt.net wrote:
 Ernest W. Durbin III ewdur...@gmail.com wrote:
 Gist containing configs and logs:
 https://gist.github.com/ewdurbin/1d9d2ea14a4231a5e7cc

 I was stumped until I saw your command-line:

   -p, /var/run/marketing-staging/unicorn.pid

 PID file path is '-P' (but we recommend using the config file for that)

 Pushing out the following:

Gorgeous! Thank you for the swift response.

 8
 Subject: [PATCH] bin/*: enforce -p/--port argument to be a valid integer

 Users may confuse '-p' with the (to-be-deprecated) '-P/--pid'
 option, leading to surprising behavior if a pathname is passed as a
 port, because String#to_i would convert it to zero, causing:

 TCPServer.new(host, port = 0)

 to bind to a random, unused port.
 ---
  bin/unicorn   | 6 +++---
  bin/unicorn_rails | 6 +++---
  2 files changed, 6 insertions(+), 6 deletions(-)

 diff --git a/bin/unicorn b/bin/unicorn
 index 01984f8..c272e43 100755
 --- a/bin/unicorn
 +++ b/bin/unicorn
 @@ -47,9 +47,9 @@ op = OptionParser.new(, 24, '  ') do |opts|
  rackup_opts[:set_listener] = true
end

 -  opts.on(-p, --port PORT,
 -  use PORT (default: #{Unicorn::Const::DEFAULT_PORT})) do |p|
 -rackup_opts[:port] = p.to_i
 +  opts.on(-p, --port PORT, Integer,
 +  use PORT (default: #{Unicorn::Const::DEFAULT_PORT})) do |port|
 +rackup_opts[:port] = port
  rackup_opts[:set_listener] = true
end

 diff --git a/bin/unicorn_rails b/bin/unicorn_rails
 index 4bd599f..b080846 100755
 --- a/bin/unicorn_rails
 +++ b/bin/unicorn_rails
 @@ -48,9 +48,9 @@ op = OptionParser.new(, 24, '  ') do |opts|
  rackup_opts[:set_listener] = true
end

 -  opts.on(-p, --port PORT,
 -  use PORT (default: #{Unicorn::Const::DEFAULT_PORT})) do |p|
 -rackup_opts[:port] = p.to_i
 +  opts.on(-p, --port PORT, Integer,
 +  use PORT (default: #{Unicorn::Const::DEFAULT_PORT})) do |port|
 +rackup_opts[:port] = port
  rackup_opts[:set_listener] = true
end

 ___
 Unicorn mailing list - mongrel-unicorn@rubyforge.org
 http://rubyforge.org/mailman/listinfo/mongrel-unicorn
 Do not quote signatures (like this one) or top post when replying
___
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying