Today I wanted to see how easy it is to use capistrano to deploy apps.
Because I’m using git it was a bit harder but not impossible, I am using the latest capistrano version (2.2.0). It’s not very hard and I like to edit something locally, git commit, git push then cap deploy and the new version is on the server immediately.
My config/deploy.rb file:
set :application, "myapp"
set :repository, "ssh://myserver/git/app.git"
set :deploy_to, "/home/mihai/apps/#{application}"
set :scm, "git"
ssh_options[:paranoid] = false
set :domain, "myserver.net"
role :app, domain
role :web, domain
role :db, domain, :primary => true
default_run_options[:pty] = true
set :user, "mihai"
set :runner, "mihai"
set :use_sudo, false
set :deploy_via, :remote_cache
set :mongrel_port, "3001"
And my config/mongrel.rb (loaded from Capfile) that is just a plain mongrel controller (no clustering):
namespace :deploy do
task :start, :roles => :app do
run "cd #{current_path} && mongrel_rails start -e production -p #{mongrel_port} -d"
end
task :restart, :roles => :app do
run "cd #{current_path} && mongrel_rails restart"
end
task :stop, :roles => :app do
run "cd #{current_path} && mongrel_rails stop"
end
end
If you are interested I can post a full tutorial including setting up apache and git on the server.