Created
June 22, 2010 17:31
-
-
Save skiz/448791 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, "myapp" | |
set :repository, "git@myhost.com:myapp.git" | |
set :user, 'deploy' | |
set :ssh_options, {:forward_agent => true} | |
# If you have previously been relying upon the code to start, stop | |
# and restart your mongrel application, or if you rely on the database | |
# migration code, please uncomment the lines you require below | |
# If you are deploying a rails app you probably need these: | |
#load 'ext/rails-database-migrations.rb' | |
#load 'ext/rails-shared-directories.rb' | |
# There are also new utility libaries shipped with the core these | |
# include the following, please see individual files for more | |
# documentation, or run `cap -vT` with the following lines commented | |
# out to see what they make available. | |
# load 'ext/spinner.rb' # Designed for use with script/spin | |
# load 'ext/passenger-mod-rails.rb' # Restart task for use with mod_rails | |
# load 'ext/web-disable-enable.rb' # Gives you web:disable and web:enable | |
# 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/#{application}" | |
# If you aren't using Subversion to manage your source code, specify | |
# your SCM below: | |
set :scm, :git | |
set :git_enable_submodules, 1 | |
set :use_sudo, :true | |
set :runner, "www-data" | |
# see a full list by running "gem contents capistrano | grep 'scm/'" | |
role :web, "myhost.com" | |
role :app, "myhost.com" | |
role :db, "myhost.com", :primary => true | |
## bdrb | |
namespace :bdrb do | |
desc "Stop the backgroundrb server" | |
task :stop, :roles => :app do | |
run "cd #{current_path} && ./script/backgroundrb stop" | |
end | |
desc "Start the backgroundrb server" | |
task :start, :roles => :app do | |
run "cd #{current_path} && RAILS_ENV=production ./script/backgroundrb start" | |
end | |
desc "Start the backgroundrb server" | |
task :restart, :roles => :app do | |
stop | |
start | |
end | |
end | |
## Migrations | |
namespace :db do | |
desc "Migrate datbase" | |
task :migrate, :roles => :db, :env => true do | |
run "cd #{current_path} && RAILS_ENV=production rake db:migrate" | |
end | |
end | |
namespace :deploy do | |
task :start, :roles => :app do | |
run "touch #{current_release}/tmp/restart.txt" | |
end | |
task :stop, :roles => :app do | |
# Do nothing. | |
end | |
desc "Restart Application" | |
task :restart, :roles => :app do | |
run "touch #{current_release}/tmp/restart.txt" | |
end | |
end | |
namespace :deploy do | |
task :localize, :roles => :app do | |
sudo "chown -R #{user}:#{runner} #{release_path}/tmp" | |
sudo "chown -R #{user}:#{runner} #{release_path}/log" | |
sudo "chown -R #{user}:#{runner} #{shared_path}/pids" | |
# Symlink Product Pictures | |
sudo "rm -rf #{release_path}/public/assets" | |
sudo "ln -nsf #{shared_path}/assets #{current_path}/public/assets" | |
sudo "chmod 777 #{release_path}/public/assets" | |
%w[database.yml].each do |f| | |
run "rm -f #{current_path}/config/#{f}" | |
run "ln -nsf #{shared_path}/system/#{f} #{current_path}/config/#{f}" | |
end | |
end | |
end | |
after "deploy:symlink", "deploy:localize" | |
before "deploy:restart", ["db:migrate"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment