Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Capistrano recip
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
Owner

happypeter commented Oct 30, 2012

Also need to uncomment in Capfile

load deploy/assets
Owner

happypeter commented Nov 3, 2012

set :use_sudo, true

this can cause problem, since cap deploy:setup will create dirs as root, thus there will be lots of Permission denied! errors

huobazi commented Jan 29, 2013

@happypeter, 第一次 setup 时

put File.read("config/database.yml.example"), "#{shared_path}/config/database.yml"

能读到文件吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment