public
Created

capistrano deploy script

  • 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 76
require 'bundler/capistrano'
require "rvm/capistrano"
 
# Development server info
set :rvm_ruby_string, 'ruby-1.9.3-p286@global'
set :rvm_type, :system
 
set :application, "newclass.org"
set :scm, :git
set :repository, "git@github.com:jexchan/re-education.git"
set :branch, 'master'
 
# use this setting for rbenv
# set :default_environment, {
# 'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
# }
 
 
desc "Run on staging server"
task :staging do
set :deploy_to, "/var/www/#{application}/staging"
end
desc "Run on production server"
task :production do
set :deploy_to, "/var/www/#{application}/production"
end
 
# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
set :user, "root"
set :group, "root"
# set :deploy_to, "/var/www/#{application}"
# set :use_sudo, false
 
set :deploy_via, :remote_cache
# set :deploy_via, :copy
# set :deploy_strategy, :export
set :keep_release, 3
 
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
 
server application, :app, :web, :db, :primary => true
 
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{File.join(current_path,'tmp','restart.txt')}"
run "nginx -s reload"
end
 
desc "Make symlink for database yaml"
task :db_symlink do
run "ln -nfs #{shared_path}/config/database.yml #{latest_release}/config/database.yml"
end
 
desc "Make symlink for uploaded files"
task :uploader_symlink do
run "rm -rf #{latest_release}/public/uploads"
run "ln -nfs #{shared_path}/public/uploads #{latest_release}/public/"
end
end
 
before "deploy:assets:precompile",
"deploy:db_symlink"
 
after "bundle:install",
"deploy:uploader_symlink"
 
desc "Backup SQL"
task :backup do
run "cd /root/sqlbackup"
run "backup perform --trigger newclass_backup -d . -c /root/sqlbackup/config.rb"
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.