-
Notifications
You must be signed in to change notification settings - Fork 82
Unicorn Stack
Intercity chef-repo supports two ways of running your application code on your server:
- Nginx + Phusion Passenger (preferred in the README and samples)
- Nginx + Unicorn
We prefer to use Phusion Passenger as the default stack because it is easier to integrate, update and deploy applications. However, we also fully support using Unicorn to run your Rails code.
The steps on this page show you how to use Unicorn instead of Phusion Passenger.
To have our cookbooks configure Unicorn as Rails application runner instead of Passenger, change role[rails_passenger]
to role[rails]
in the run_list
key of your host .json
configuration.
So to get Unicorn with MySQL you set:
{
"run_list": ["role[mysql]", "role[rails]"],
... other configuration
And for Unicorn with PostgreSQL you set:
{
"run_list": ["role[postgresql]", "role[rails]"],
... other configuration
Add the capistrano3-unicorn
gem to your Gemfile
:
gem "capistrano3-unicorn", "~> 0.2.1", group: :development
and run bundle
.
In your Capfile
add the line:
require 'capistrano3/unicorn'
In config/deploy.rb
add these lines:
set :unicorn_config_path, "#{current_path}/config/unicorn.rb"
set :bundle_bins, fetch(:bundle_bins, []).push("unicorn")
And add unicorn.rb
to the :linked_files
setting so it looks like:
set :linked_files, %w{config/database.yml .rbenv-vars config/unicorn.rb}
Also in config/deploy.rb
replace the full namespace :deploy do
with:
namespace :deploy do
task :restart do
invoke 'unicorn:restart'
end
after 'deploy:publishing', 'restart'
end
That's it! You can now deploy your app and start/reload Unicorn with:
cap production deploy