Skip to content

Instantly share code, notes, and snippets.

@vivekkhokhar
Created August 13, 2012 15:35
Show Gist options
  • Select an option

  • Save vivekkhokhar/3341939 to your computer and use it in GitHub Desktop.

Select an option

Save vivekkhokhar/3341939 to your computer and use it in GitHub Desktop.
require 'bundler/capistrano'
set :whenever_command, "bundle exec whenever"
set :whenever_variables, defer { "'environment=production&application=#{application}'" }
set :whenever_roles, 'whenever'
require "whenever/capistrano"
set :repository, "[email protected]:somerepo.git"
set :branch, do
Capistrano::CLI.ui.ask("\nType the branch name. Default would be:") {|q| q.default = 'master' }
end
set :deploy_via, :remote_cache
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
set :user, "ubuntu"
set :scm, :git
set :keep_releases, 4
task :stage do
set :application, "project_name_stage"
server 'ec2-hostname-stage.com', :app, :whenever, :primary => true
end
task :live do
set :application, "project_name_live"
server 'ec2-hostname-live1.compute-1.amazonaws.com', :app, :primary => true
server 'ec2-hostname-live2.compute-1.amazonaws.com', :app, :whenever
end
namespace :deploy do
after 'deploy:create_symlink', 'deploy:symlink_system_folder', 'deploy:copy_config_files'
after "deploy:update", "deploy:cleanup"
task :symlink_system_folder do
run "mkdir -p #{shared_path}/data && rm -rf #{current_path}/data && ln -s #{shared_path}/data #{current_path}/data"
end
task :copy_config_files do
puts "COPY CONFIG: #{application}"
case application
when "project_name_live"
run "cp #{current_path}/config/database_live.yml #{current_path}/config/database.yml"
when "project_name_stage"
run "cp #{current_path}/config/database_stage.yml #{current_path}/config/database.yml"
end
end
task :start, :roles => :app, :except => { :no_release => true } do
end
task :stop, :roles => :app, :except => { :no_release => true } do
end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path, 'tmp', 'restart.txt')}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment