Skip to content

Instantly share code, notes, and snippets.

@allenfantasy
Forked from happypeter/deploy.rb
Created November 3, 2013 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allenfantasy/7288560 to your computer and use it in GitHub Desktop.
Save allenfantasy/7288560 to your computer and use it in GitHub Desktop.
require "bundler/capistrano"
set :application, "blog"
set :repository, "git@github.com:happypeter/blog.git"
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
set :user, "deployer"
set :deploy_to, "/home/#{user}/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, true
set :branch, "master"
default_run_options[:pty] = true
server "billie.happyec.org", :web, :app, :db, :primary => true
namespace :deploy do
%w[start stop restart].each do |command|
desc "#{command} unicorn server"
task command, :roles => :app, except: {no_release: true} do
run "/etc/init.d/unicorn_#{application} #{command}"
end
end
desc "things I need to do after deploy:setup"
task :setup_config, :roles => :app do
run "#{try_sudo} ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
run "#{try_sudo} ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}"
run "mkdir -p #{shared_path}/config"
put File.read("config/database.yml.example"), "#{shared_path}/config/database.yml"
puts "Now edit the config files in #{shared_path}. create db"
end
after "deploy:setup", "deploy:setup_config"
task :symlink_config, :roles => :app do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
after "deploy:finalize_update", "deploy:symlink_config"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment