Created
April 12, 2009 12:25
-
-
Save minitau/93979 to your computer and use it in GitHub Desktop.
tracks with passenger
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
############################################################# | |
# This file is designed as a starting point to use | |
# capistrano to deploy the trunk of tracks to a webhost | |
# where it is served using Phusion Passenger. For more | |
# info on getting started with Passenger, see | |
# http://www.modrails.com/ | |
############################################################# | |
############################################################# | |
# Application | |
############################################################# | |
set :application, "tracks" | |
set :deploy_to, "/var/rails/#{application}" | |
############################################################# | |
# Settings | |
############################################################# | |
default_run_options[:pty] = true | |
ssh_options[:forward_agent] = true | |
set :use_sudo, false | |
set :scm_verbose, true | |
set :rails_env, "production" | |
############################################################# | |
# Servers | |
############################################################# | |
set :user, "rails" | |
set :domain, "ubu1" | |
server domain, :app, :web | |
role :db, domain, :primary => true | |
############################################################# | |
# Git | |
############################################################# | |
set :scm, :git | |
set :branch, "v1.7" | |
set :repository, "ssh://localhost/path/to/tracks/" | |
set :deploy_via, :remote_cache | |
# for copy | |
#set :repository, "." | |
#set :deploy_via, :copy | |
#set :copy_dir, "./tmp/deploy" | |
#set :copy_remote_dir, "~/tmp/deploy" | |
############################################################# | |
# Passenger | |
############################################################# | |
namespace :deploy do | |
desc "setup shared_path" | |
task :after_setup do | |
run "mkdir #{shared_path}/config" | |
upload | |
end | |
desc "upload" | |
task :upload do | |
top.upload "config/database.yml", "#{shared_path}/config/database.yml" | |
top.upload "config/site.yml", "#{shared_path}/config/site.yml" | |
end | |
task :after_update_code do | |
run "ln -s #{shared_path}/config/database.yml #{release_path}/config/database.yml" | |
run "ln -s #{shared_path}/config/site.yml #{release_path}/config/site.yml" | |
end | |
desc "Symlink config files" | |
task :before_symlink do | |
run "rm #{release_path}/public/.htaccess" #not compatible with Passenger | |
# run "ln -s #{shared_path}/config/environment.rb #{release_path}/config/environment.rb" | |
end | |
# Restart passenger on deploy | |
desc "Restarting mod_rails with restart.txt" | |
task :restart, :roles => :app, :except => { :no_release => true } do | |
run "touch #{current_path}/tmp/restart.txt" | |
end | |
[:start, :stop].each do |t| | |
desc "#{t} task is a no-op with mod_rails" | |
task t, :roles => :app do ; end | |
end | |
end | |
namespace :db do | |
desc 'Dumps the production database to db/production_data.sql on the remote server' | |
task :remote_db_dump, :roles => :db, :only => { :primary => true } do | |
run "cd #{deploy_to}/#{current_dir} && " + | |
"rake RAILS_ENV=#{rails_env} db:dump_sql --trace" | |
end | |
desc 'Downloads db/production_data.sql from the remote production environment to your local machine' | |
task :remote_db_download, :roles => :db, :only => { :primary => true } do | |
execute_on_servers(options) do |servers| | |
self.sessions[servers.first].sftp.connect do |tsftp| | |
tsftp.download!("#{deploy_to}/#{current_dir}/db/production_data.sql", "db/production_data.sql") | |
end | |
end | |
end | |
desc 'Cleans up data dump file' | |
task :remote_db_cleanup, :roles => :db, :only => { :primary => true } do | |
execute_on_servers(options) do |servers| | |
self.sessions[servers.first].sftp.connect do |tsftp| | |
tsftp.remove! "#{deploy_to}/#{current_dir}/db/production_data.sql" | |
end | |
end | |
end | |
desc 'Dumps, downloads and then cleans up the production data dump' | |
task :remote_db_runner do | |
remote_db_dump | |
remote_db_download | |
remote_db_cleanup | |
end | |
end | |
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
git clone git://github.com/bsag/tracks.git | |
cd tracks | |
git checkout -b v1.7 origin/v1.7_branch | |
cd config | |
cp database.yml.tmpl database.yml | |
cp deploy.rb-example deploy.rb | |
cp site.yml.tmpl site.yml | |
vi database.yml | |
vi deploy.rb (see above.) | |
vi site.yml | |
cd .. | |
rake db:migrate:all | |
cap deploy:setup | |
cap deploy:migrations |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment