Forked from ThePixelDeveloper/PHP Capistrano Recipe.rb
Created
December 4, 2009 11:50
-
-
Save jianyuan/248987 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shared directories, these are directories containing generated content which should not be wiped out during deployments. | |
set :shared_children, %w(config logs) | |
# Application name | |
set :application, "domain.com" | |
# Path where files are deployed to ... | |
set :deploy_to, "/var/www/#{application}/#{stage}" | |
# Commands on the server are run as the following user : | |
set :runner, "website" | |
set :user, "website" | |
# Sudo isn | |
set :use_sudo, false | |
# I am using bazaar, so I specify it here | |
set :scm, :bzr | |
set :deploy_via, :export | |
# This is the path to the code repository on the server, remember when you pushed the code up to the server? | |
set :repository, "/var/www/repositories/website.com/" | |
# ---------------------------------------------------------------------------- | |
# Role settings | |
# ---------------------------------------------------------------------------- | |
role :web, "#{application}" | |
# ---------------------------------------------------------------------------- | |
# SSH settings | |
# ---------------------------------------------------------------------------- | |
ssh_options[:keys] = %w(/home/mathew/.ssh/private_key) | |
ssh_options[:port] = 22 | |
namespace :deploy do | |
desc <<-DESC | |
[internal] Touches up the released code. This is called by update_code | |
after the basic deploy finishes. It assumes a Rails project was deployed, | |
so if you are deploying something else, you may want to override this | |
task with your own environment's requirements | |
DESC | |
task :finalize_update, :except => { :no_release => true } do | |
# link log and upload directories | |
run "rmdir #{latest_release}/application/logs" | |
run "rmdir #{latest_release}/upload" | |
run "ln -s #{shared_path}/logs #{latest_release}/application/logs" | |
run "ln -s #{shared_path}/upload #{latest_release}/upload" | |
# copy configuration files | |
run "cp -rf #{shared_path}/config/ #{latest_release}/application/" | |
# copy index.php | |
run "cp -f #{shared_path}/index.php #{latest_release}/index.php" | |
# chmod directories and files | |
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 | |
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 | |
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