Capistrano 2 on Site5
Posted by Giovanni Intini | Filed under Capistrano, Programming, Rails, Ruby, Site5
I finally took the time to browse the capistrano 2 sources, and after reaching enlightenment I was able to write a deploy.rb file (yes I still use capify + deploy.rb instead of Capfile) that works really fine and really sweet on Site5.
Without further ado, I introduce you to deploy.rb extreme Site5 version
# Necessary to run on Site5 set :use_sudo, false set :group_writable, false # Less releases, less space wasted set :keep_releases, 2 # The mandatory stuff set :application, "YOUR_APP_NAME" set :user, "SSH_USERNAME" set :repository, "URL_FOR_YOUR_REPOSITORY" # SCM information set :scm_username, "SCM_USERNAME" set :scm_password, Proc.new { CLI.password_prompt "SVN Password: "} # This is related to site5 too. set :deploy_to, "/home/#{user}/apps/#{application}" role :app, "SERVERNAME" role :web, "SERVERNAME" role :db, "SERVERNAME", :primary => true # In the deploy namespace we override some default tasks and we define # the site5 namespace. namespace :deploy do desc <<-DESC Deploys and starts a `cold' application. This is useful if you have not \ deployed your application before, or if your application is (for some \ other reason) not currently running. It will deploy the code, run any \ pending migrations, and then instead of invoking `deploy:restart', it will \ invoke `deploy:start' to fire up the application servers. DESC # NOTE: we kill public_html so be sure to have a backup or be ok with this application # being the default app for the domain. task :cold do update site5::link_public_html site5::kill_dispatch_fcgi end desc <<-DESC Site5 version of restart task. DESC task :restart do site5::kill_dispatch_fcgi end namespace :site5 do desc <<-DESC Links public_html to current_release/public DESC task :link_public_html do run "cd /home/#{user}; rm -rf public_html; ln -s #{current_path}/public ./public_html" end desc <<-DESC Kills Ruby instances on Site5 DESC task :kill_dispatch_fcgi do run "skill -u #{user} -c ruby" end end end
May your deploys be merry and bright and I wish you all your applications be white
August 1st, 2007 at 1:28 am
[...] Capistrano 2 on Site5 Nice and working recipe for Capistrano on Site5. (tags: rails 4trm ruby rubyonrails capistrano site5) Last Modified : August 1st, 2007 Filed under : Del.icio.us Navigate : Previous post / Share : [...]
August 2nd, 2007 at 1:43 pm
Hi!
I have a little different deploy.rb file. Here it is:
set :run_method, :run #Is the same as :use_sudo, false
set :group_writable, false #Very important in site5
set :application, “APP_NAME”
#I use the main user account provided by site5
set :username, “username”
set :password, “password”
#I use svn+ssh protocol
#My repository is in ~/svn/[trunk|branches|tags]
set :repository, “svn+ssh://#{user}@servername/home/#{user}/svn/trunk”
set :deploy_via, :remote_cache
#I created a directory in ~/ with the APP_NAME and then linked public_html to /APP_NAME/current/public permanently (without a task)
set :deploy_to, “/APP_NAME”
role :app, “SERVERNAME”
role :web, “SERVERNAME”
role :db, “SERVERNAME”, :primary => true
#Now, I use one of the new features of Cap2, the callbacks.
#This callbacks make two specific tasks, restart fcgi processes and symlink to database configuration
after “deploy:restart”, :restart_web_server
after “deploy:update_code”, :symlink_to_database_yml
#I do not add a desc to the task, I prefer a long name
task :restart_web_server, :roles => :web do
run “skill -9 -u #{user} -c dispatch.fcgi”,
end
task :symlink_to_database_yml, :roles => :web do
run “ln -s #{shared_path}/config/database.yml #{current_path}/config/database.yml”
end
And that’s all.
August 2nd, 2007 at 11:44 pm
[...] Intini has posted a Capistrano 2 recipe for deploying to Site5. There’s another in variation in the comments to his [...]
August 3rd, 2007 at 9:32 am
Markus when using callbacks don’t you get errors with the default capistrano tasks? I feel it’s cleaner to override the tasks that are not pertinent to site5.
August 3rd, 2007 at 2:43 pm
Giovanni: The only task you may override is deploy:restart, to substitute ‘process/reaper’ for ‘skill … dispatch.fcgi’, it’s the only error (actually is a notification, not an error) I take in my ‘cap deploy’ output.
Bye!
August 6th, 2007 at 1:22 pm
There’s also the spinner script in deploy:cold.
August 6th, 2007 at 1:38 pm
I ignore it. And I have only used deploy:cold in the first deployment, keeping my deploy.rb file as simple as possible.
February 3rd, 2008 at 5:57 am
What does SCM stand for?
Thanks!
Brian
March 28th, 2008 at 12:00 am
SCM => Source Control Management