Beruflich Dokumente
Kultur Dokumente
Capistrano (Part 1)
What is Capistrano?
Capistrano is a remote server automation and
deployment tool written in ruby. Put simply, it helps you
get your code on a server and easily run commands on
a server so your application is ready for the world to
use.
Using Capistrano
The first step in using Capistrano is installing the
Capistrano gem on your local machine. Capistrano only
requires that you have access to your server via Secure
Shell (SSH).
geminstallcapistrano
require'bundler/capistrano'#forbundlersupport
set:application,"setyourapplicationnamehere"
set:repository,"setyourrepositorylocationhere"
set:user,'USERNAME'
set:deploy_to,"/home/#{user}/#{application}"
set:use_sudo,false
set:scm,:git
default_run_options[:pty]=true
role:web,"96.8.123.64"
#YourHTTPserver,Apache/etc
role:app,"96.8.123.64"
#Thismaybethesameasyour`Web`server
#ifyouwanttocleanupoldreleasesoneachdeploy
uncommentthis:
#after"deploy:restart","deploy:cleanup"
#ifyou'restillusingthescript/reaperhelperyouwillneed
#thesehttp://github.com/rails/irs_process_scripts
#IfyouareusingPassengermod_railsuncommentthis:
namespace:deploydo
task:startdo;end
task:stopdo;end
task:restart,:roles=>:app,:except=>{:no_release=>
true}do
run"#{try_sudo}touch
#{File.join(current_path,'tmp','restart.txt')}"
end
end
#ifyouwanttocleanupoldreleasesoneachdeploy
uncommentthis:
#after"deploy:restart","deploy:cleanup"
#ifyou'restillusingthescript/reaperhelperyouwillneed
#thesehttp://github.com/rails/irs_process_scripts
#IfyouareusingPassengermod_railsuncommentthis:
namespace:deploydo
task:startdo;end
task:stopdo;end
task:restart,:roles=>:app,:except=>{:no_release=>
true}do
run"#{try_sudo}touch
#{File.join(current_path,'tmp','restart.txt')}"
end
end
In the previous post I left off with the set :scm, :git
line, so I will start with the following line:
default_run_options[:pty]=true
The above two lines assign the web and app roles to
specific servers. Capistrano roles allow you to have
different servers handle different parts of the app
(server for app, server for handling requests, and
server for the database). We used one server for all