Created
March 11, 2013 09:25
-
-
Save jexchan/5133028 to your computer and use it in GitHub Desktop.
capistrano deploy script
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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment