kalys/capistrano-nginx-unicorn — pull request #20 by bruno- (2014-03-22 13:01:48+00:00)
Title: Cap 3 more idiomatic support and refactoring

Hi @kalys,
here's one big pull request that should, on a high level, bring:
- more idiomatic capistrano 3 support
- proper (I hope) solution for invoking bundler in `unicorn_init` file
- other stuff

Kalys, I see you made some commits since I pulled the v0.1 branch yesterday.. that's why pull request can't be automatically merged. I'm happy to see your commit went in the same direction as this pull request (better variable defaults, splitting main tasks file).
Before dealing with the rebase, let's discuss if the pull request will get merged, since there are so many changes (I hope yes).

Let me go into more details about the changes/improvements made:
- variable defaults are loaded cap 3 way (using the `load:defaults` task)
- improved sudo invocation (no need for `sudo` variable anymore)
- helper methods extracted to a separate module
- `tasks.rb` broken down into 3 files (for nginx, unicorn and logrotate)
- individual tasks split down to smaller tasks (i.e. `unicorn:setup` => `unicorn:setup_initializer`, `unicorn:setup_app_config`)
- nginx and unicorn tasks are "plugged in" to capistrano process (properly I hope), not just executed at the end, after `deploy:finalize`
- all tasks are now more idempotent (if a config file already exists on the server, it won't get uploaded again). This should speed up things too.
- built-in support for stages. For example: unicorn service on a server won't be `unicorn_myapp`, but `unicorn_myapp_production`. That way multiple application stages (testing, qa, staging) can be deployed to server if necessary (my company has a need for this).
- proper support for invoking `bundle unicorn` via [this](https://github.com/bruno-/capistrano-nginx-unicorn/blob/cap3-support-refactoring/lib/capistrano/nginx_unicorn/helpers.rb#L8). I tested this by using rbenv. It should work for rvm too (when using capistrano/rvm plugin).

All of this is now working smooth for me on capistrano 3.1, rbenv, ruby 1.9.3 and deploying to ubuntu VPS.
Btw. I did quite some testing.

I'll be glad to answer questions or discuss any decision!

Suggestions:
- testing with rvm. I'm gonna do this today, I'd appreciate your feedback too.
- Kalys, can you please have a look at this and confirm you think we should work towards merging this?