samuelkadolph/unicorn-rails — pull request #11 by sikachu (2014-09-03 02:15:54+00:00)
Title: Inherit host and port from `rails server`

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