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

Only set unicorn options if config file does not exist #8

Closed beedub closed 10 years ago

beedub commented 10 years ago

If there exists a config file, then it seems likely will/should specify the listener, worker_processes, and timeout settings (among other settings).

samuelkadolph commented 10 years ago

Does specifying them in the file not override the hash?

beedub commented 10 years ago

The main issue I had was that the listeners are additive, so when I specified a listener to port 6000 in my config/unicorn/development.rb, unicorn would bind to 3000 (the rails default) and 6000 when I only wanted 6000.

nozpheratu commented 10 years ago

Aha! I spent an hour debugging before I finally stumbled on this ticket. My application was running smooth on the default settings for the most part, and my unicorn.rb config settings are only there for changes that need to be made for production.

So my config file end up looking something like this:

if ENV['RAILS_ENV'] == "production"
....
end

I recently did an update from v 1.1.0, and somewhere along the lines between that version and the current stable release it seems that if the config file is present in development environment then unicorn-rails assume ANY defaults, and assumes that the config file defines everything. This of course broke in my case.

Can we change this to behave in a way that will make everyone happy? Maybe having environment-specific config files?

samuelkadolph commented 10 years ago

Currently it should check for environment specific files (config/unicorn/RAILS_ENV.rb) and use that if found. The only issue with the current release is that if you have a config file, you don't get a default listener. And for that I haven't found a easy and clean solution to check if you have a listen statement in your config file.