Learn how to use Capistrano to automate the deployment of your Ruby on Rails applications. Apply best practices and add-ons for customizing Capistrano.
7. Example Script
set :application, "set your application name here”
role :app, "your app-server here”
role :web, "your web-server here”
role :db, "your db-server here", :primary => true
8. Example Script (git)
set :scm, :git
set :repository, “username@hostname:myapp.git”
set :branch, “master”
set :deploy_via, :remote_cache
9. Example Script
(Passenger)
namespace :deploy do
desc "Restarting mod_rails with restart.txt”
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{current_path}/tmp/restart.txt”
end
[:start, :stop].each do |t|
desc "#{t} task is a no-op with mod_rails”
task t, :roles => :app do ; end
end
end
10. Example Script (mongrel)
require 'mongrel_cluster/recipes'
namespace :deploy do
task :restart do
restart_mongrel_cluster
end
end
21. config/deploy.rb:
set :stages, %w(production staging)
set :default_stage, "staging”
require 'capistrano/ext/multistage‟
Add users for each stage:
$ sudo useradd staging
$ sudo useradd production