public
Last active — forked from albertoleal/deploy.rb

  • Download Gist
deploy.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
set :application, "your_application_name"
set :ip_address , "000.000.000.000"
 
set :scm, :git
set :repository, "git@github.com:albertoleal/OlaMundo.git"
set :branch, "master"
set :deploy_via, :remote_cache # Deploy only the changes you have made since last deploy.
 
set :user , "albertoleal"
set :deploy_to, "/home/albertoleal/#{application}"
set :shared_directory, "#{deploy_to}/shared"
set :use_sudo, false
set :group_writable, false
set :scm_verbose, true
default_run_options[:pty] = true
 
# ROLES
server ip_address, :app, :web, :db, :primary => true
 
# HOOKS
after 'deploy:setup', 'db:setup'
 
after 'deploy:update_code' do
db.symlink
assets.symlink
end
before 'deploy:migrate' do
deploy.bundle_install
end
 
# TASKS
namespace :deploy do
# 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
 
desc "Run bundle install"
task :bundle_install do
run "cd #{release_path}/ && bundle install"
end
end
 
namespace :db do
desc "upload database.yml"
task :setup do
upload File.join(File.dirname(__FILE__),"database.yml"), "#{shared_path}/database.yml"
end
 
desc "link database.yml"
task :symlink do
run "ln -s #{shared_path}/database.yml #{release_path}/config/database.yml"
end
 
desc "seed database"
task :seed do
run "cd #{current_path} && rake db:seed RAILS_ENV=production"
end
end
 
namespace :assets do
desc "assets symlink"
task :symlink, :roles => :app do
run <<-CMD
rm -rf #{current_path}/public/images/system &&
ln -nfs #{shared_path}/system #{release_path}/public/images/system
CMD
end
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.