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

Inherit host and port from `rails server` #11

Closed sikachu closed 10 years ago

sikachu commented 10 years ago

This makes it so that it will tries to use the defaults given by Rails when user doesn't have listen configuration in their unicorn.rb.

Before this patch:

=> No listen in config/unicorn.rb

$ rails server
=> Booting Unicorn
=> Rails 4.1.5 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
I, [2014-09-02T22:06:46.940472 #66762]  INFO -- : listening on addr=0.0.0.0:8080 fd=11

$ rails server -p 3001
=> Booting Unicorn
=> Rails 4.1.5 application starting in development on http://0.0.0.0:3001
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
I, [2014-09-02T22:06:46.940472 #66762]  INFO -- : listening on addr=0.0.0.0:8080 fd=11

=> With listen 5000 in config/unicorn.rb

$ rails server
=> Booting Unicorn
=> Rails 4.1.5 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
I, [2014-09-02T22:06:46.940472 #66762]  INFO -- : listening on addr=0.0.0.0:5000 fd=11

$ rails server -p 3001
=> Booting Unicorn
=> Rails 4.1.5 application starting in development on http://0.0.0.0:3001
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
I, [2014-09-02T22:06:46.940472 #66762]  INFO -- : listening on addr=0.0.0.0:5000 fd=11

After this patch:

=> No listen in config/unicorn.rb

$ rails server
=> Booting Unicorn
=> Rails 4.1.5 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
I, [2014-09-02T22:06:46.940472 #66762]  INFO -- : listening on addr=0.0.0.0:3000 fd=11

$ rails server -p 3001
=> Booting Unicorn
=> Rails 4.1.5 application starting in development on http://0.0.0.0:3001
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
I, [2014-09-02T22:06:46.940472 #66762]  INFO -- : listening on addr=0.0.0.0:3001 fd=11

=> With listen 5000 in config/unicorn.rb

$ rails server
=> Booting Unicorn
=> Rails 4.1.5 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
I, [2014-09-02T22:06:46.940472 #66762]  INFO -- : listening on addr=0.0.0.0:5000 fd=11

$ rails server -p 3001
=> Booting Unicorn
=> Rails 4.1.5 application starting in development on http://0.0.0.0:3001
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
I, [2014-09-02T22:06:46.940472 #66762]  INFO -- : listening on addr=0.0.0.0:5000 fd=11

Note that it might looks weird for the last case, but that's an expected outcome given user overrides config/unicorn.rb themselves.

Fixes #9

sikachu commented 10 years ago

Would you mind taking another look at this?

samuelkadolph commented 10 years ago

Released as 2.2.0

sikachu commented 10 years ago

Awesome. Thank you!