Created
October 30, 2009 04:17
-
-
Save tjboudreaux/222115 to your computer and use it in GitHub Desktop.
This file contains 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
set :application, "app" | |
set :domain , "domain" | |
set :repository, "your repository" | |
set :slice_ip, '##.###.###.###' | |
# If you aren't deploying to /u/apps/#{application} on the target | |
# servers (which is the default), you can specify the actual location | |
# via the :deploy_to variable: | |
set :deploy_to, "/var/www/vhosts/#{domain}/htdocs" | |
set :document_root, "/var/www/vhosts/#{domain}/htdocs/current" | |
# If you aren't using Subversion to manage your source code, specify | |
# your SCM below: | |
set :scm, :git | |
# SSH Settings | |
set :user, "sshuser" | |
set :password, "sshpw" | |
set :use_sudo, true | |
set :ssh_options, {:forward_agent => true} | |
# Apache Settings | |
set :apache_dir, "/etc/apache2" | |
server "#{slice_ip}", :app, :db, :web, :primary => true | |
# We need to over write a lot of the core functionality here | |
# since we don't need migrations, lots of the symlink stuff | |
# and server restarting. | |
# This is strictly for PHP deploys | |
namespace :deploy do | |
task :update do | |
update_code | |
symlink | |
end | |
desc "finalize updates" | |
task :finalize_update do | |
run "chmod -R g+w #{releases_path}/#{release_name}" | |
end | |
desc "setup symlinks" | |
task :symlink do | |
sudo "ln -nfs #{current_release} #{deploy_to}/#{current_dir}" | |
sudo "ln -nfs #{deploy_to}/#{current_dir} #{document_root}" | |
end | |
task :migrate do | |
# nothing | |
end | |
task :restart do | |
# nothing | |
end | |
"setup vhost file" | |
task :vhost do | |
template = File.read(File.join(File.dirname(__FILE__), 'config', 'vhost.conf.erb')) | |
put ERB.new(template).result(binding), "#{shared_path}/config/#{domain}.conf" | |
sudo "mv #{shared_path}/config/#{application}.conf #{apache_dir}/sites-available/#{application}.conf" | |
sudo "ln -nfs #{apache_dir}/sites-available/#{application}.conf #{apache_dir}/sites-enabled/#{application}.conf" | |
sudo "/ect/init.d/apache2 restart" | |
end | |
desc "add dns records" | |
task :add_dns_records do | |
sudo "slicehost-dns add #{domain} #{slice_ip}" | |
sudo "slicehost-dns add_a #{domain} staging #{slice_ip}" | |
sudo "slicehost-dns google_apps" | |
end | |
end | |
# Now we can get back into some regular recipe stuff | |
task :after_symlink do | |
# sync up the images and other static content | |
run "ln -nsf #{shared_path}/images #{document_root}/images" | |
end | |
#managing apache restarts | |
namespace :apache do | |
[:stop, :start, :restart, :reload].each do |action| | |
desc "#{action.to_s.capitalize} Apache" | |
task action, :roles => :web do | |
invoke_command "/etc/init.d/apache2 #{action.to_s}", :via => run_method | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment