Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
capistrano deploy script
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, ""
set :scm, :git
set :repository, ""
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"
desc "Run on production server"
task :production do
set :deploy_to, "/var/www/#{application}/production"
# 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"
desc "Make symlink for database yaml"
task :db_symlink do
run "ln -nfs #{shared_path}/config/database.yml #{latest_release}/config/database.yml"
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/"
before "deploy:assets:precompile",
after "bundle:install",
desc "Backup SQL"
task :backup do
run "cd /root/sqlbackup"
run "backup perform --trigger newclass_backup -d . -c /root/sqlbackup/config.rb"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment