Capistrano
From Apis Networks Wiki
Note: If you're having trouble with 'require' failing in server-side scripts running over Capistrano, read Capistrano and Environment Variables
Apis Networks user Jonnii requested my deployment recipe for Capistrano, I realize that this may be of more help down the road so here it is! The two large downsides to my methods, there's currently no support for rollbacks due to Apis' use of relative symlinks for public_html instead of absolute (absolute is what Capistrano uses by default). Also, I have yet to play around with setting up multiple server deployment. I'm looking for a method of deploying to the same server, but with multiple user accounts on that server.
If anyone has any tips on how to do this, or can improve on the symlink method feel free to email me: cbergy [at] shaw.ca
Thanks!
# REQUIRED VARIABLES set :application, "appname" set :repository, "--username user --password pass http://path/to/repo" # ROLES role :web, "gauss.apisnetworks.com" role :app, "gauss.apisnetworks.com" role :db, "gauss.apisnetworks.com", :primary => true # OPTIONAL VARIABLES set :user, "user@domain.com" set :deploy_to, "/home/apis_user/#{application}" set :release, now.strftime("%Y%m%d%H%M%S") # Used for Apis Networks set :new_release_path, "releases/#{release}/public/" set :use_sudo, false # TASKS desc <<DESC An imaginary backup task. (Execute the 'show_tasks' task to display all available tasks.) DESC task :backup, :roles => :db, :only => { :primary => true } do # the on_rollback handler is only executed if this task is executed within # a transaction (see below), AND it or a subsequent task fails. on_rollback { delete "/tmp/dump.sql" } run "mysqldump -u theuser -p thedatabase > /tmp/dump.sql" do |ch, stream, out| ch.send_data "thepassword\n" if out =~ /^Enter password:/ end end # My Tasks task :after_deploy, :roles => :app do cleanup run "rm -rf public_html" run "rm -rf #{application}/current" run "ln -nfs #{application}/#{new_release_path} public_html" end task :after_rollback, :roles => :app do print "Now the fun part, you get to manually connect and create the symlink for public_html to the previous release!" end task :before_restart, :roles => :app do run "chmod -R 755 *" end task :restart, :roles => :app do # Currently overwritten, due to lack of 'current' symlink dir use # Not using the spawner/spinner/reaper combo anyway end
