capistrano-plugins / capistrano-unicorn-nginx

Capistrano tasks for automatic and sensible unicorn + nginx configuration
MIT License
175 stars 81 forks source link

odd behavior related to 'unicorn_use_tcp' #89

Open nextofsearch opened 8 years ago

nextofsearch commented 8 years ago

Hi,

I just found out a very odd behavior related to 'unicorn_use_tcp'

If I don't set any value for :unicorn_use_tcp, 1) when there is only one server, 'unicorn_use_tcp' works as false. 2) when there are more than 1 server, 'unicorn_use_tcp' seems to be true. This results in a disaster since the upstream setting in the nginx conf goes wrong when running 'cap nginx:setup'

1) upstream unicorn_tp_staging { server unix:/home/xxxxxxxxxxx/shared/sockets/unicorn.tp_staging.sock fail_timeout=0; }

2) upstream unicorn_tp_staging { server 54.xxx.xxx.xxx:8080 fail_timeout=0; server 54.xxx.xxx.xxx:8080 fail_timeout=0; }

My case was, that it worked well in a staging environment with 1 API server then it shut down in a production environment with multiple servers. It can be avoided by setting it explicitly as you want but this is not what I expected and I think it definitely needs to be fixed.

Thanks,

nextofsearch commented 8 years ago

I just found out that this is an intended feature as described here

set :unicorn_use_tcp, -> { roles(:app).count > 1 }

We have multiple servers when each server has nginx (proxy) and unicorn communicate over unix socket behind a load balancer.

nextofsearch commented 8 years ago

I think changing a default value by a certain condition is not a good idea. Not sure which case is more common, though.