samuelkadolph / unicorn-rails

unicorn-rails is a simple gem that sets the default server for rack (and rails) to unicorn.
MIT License
127 stars 22 forks source link

2.0.0 Doesn't bind worker addr/port correctly #9

Closed zombiebsas closed 10 years ago

zombiebsas commented 10 years ago

When I start Unicorn with:

rails s -b $IP -p $PORT

I'm getting this error:

screen shot 2014-04-25 at 1 03 33 am

If I downgrade the gem version to 1.1.0, Unicorn starts working again. What am I doing wrong?

samuelkadolph commented 10 years ago

This is probably caused by e6b22d51c71bb79ac9d9a89ddcb66e8e2f5e1812 and you have a config file that does not have a listen statement in it so unicorn inserts its default of "0.0.0.0:8080".

zd-dalibor commented 10 years ago

OK, this is nice, so how to call "listen" statement in config file with host and port supplied with "rails sever" command?

jairodemorais commented 10 years ago

@dalibor983 you can try something like this:

after_fork do |server, worker| addr = "127.0.0.1:3000" server.listen(addr, :tries => -1, :delay => 5, :tcp_nopush => true)

sikachu commented 10 years ago

I actually think it make more sense to honor Rails' setting if user doesn't have listen in their unicorn.rb, as by ignoring that it actually make it impossible to be able to set the port using -p option.

Let me test to see if these are the case:

If so, I'll submit a PR with change to make it respect rails s -p ____.

samuelkadolph commented 10 years ago

I started looking for a clean way of detecting a listen statement was used in the unicorn config file but haven't had much time to work on it so a PR would be welcome.

sikachu commented 10 years ago

@samuelkadolph would you mind reviewing #11? I think that's an adequate solution.