Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ThePixelDeveloper
Created October 15, 2009 17:05
Show Gist options
  • Star 31 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save ThePixelDeveloper/211105 to your computer and use it in GitHub Desktop.
Save ThePixelDeveloper/211105 to your computer and use it in GitHub Desktop.
# --------------------------------------------
# General
# --------------------------------------------
set :shared_children, %w(cache logs) # Shared directories, these directories contain generated content which should not be wiped out during deployments.
set :application, "domain.com" # Application name
set :deploy_to, "/var/www/#{application}/#{stage}" # Path where files are deployed to ...
# --------------------------------------------
# Server
# --------------------------------------------
# Commands on the server are run as the following user :
set :runner, "website"
set :user, "website"
set :use_sudo, false # sudo isn't required for my deployment.
# --------------------------------------------
# Repository
# --------------------------------------------
set :scm, :bzr # I am using bazaar, so I specify it here
set :deploy_via, :export # This will use bzr export as the method of obtaining the code from the repository.
set :repository, "/home/user/repositories/domain.com" # This is the path to the repository on the server, we pushed the code here earlier.
role :web, "#{application}"
# --------------------------------------------
# SSH
# --------------------------------------------
ssh_options[:keys] = %w(/home/user/.ssh/private_key) # SSH key
ssh_options[:port] = 22
# --------------------------------------------
# Overloaded Methods.
# --------------------------------------------
namespace :deploy do
task :finalize_update, :except => { :no_release => true } do
# Make sure the log and upload directories do not exist.
run "rmdir #{latest_release}/application/logs"
run "rmdir #{latest_release}/application/cache"
# Symlink the shared directories to the directories in your application.
run "ln -s #{shared_path}/logs #{latest_release}/application/logs"
run "ln -s #{shared_path}/cache #{latest_release}/application/cache"
# chmod the files and directories.
run "find #{shared_path} -type d -exec chmod 0755 {} \\;"
run "find #{latest_release} -type d -exec chmod 0755 {} \\;"
run "find #{latest_release} -type f -exec chmod 644 {} \\;"
end
namespace :web do
task :disable do
# When cap deploy:web:disable is run, copy a maintenance.html page from the shared directory
# to the webroot. You will typically have Apache check for this file and disable access to the
# site if it exists.
run "cp #{shared_path}/maintenance.html #{latest_release}"
run "echo #{stage}"
end
task :enable do
run "rm -f #{latest_release}/maintenance.html"
end
end
end
# Hook the web disable and disable events into the deployment.
after "deploy:update_code", "deploy:web:disable"
after "deploy:symlink", "deploy:web:enable"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment