Created
January 26, 2012 23:57
-
-
Save hakagura/1685968 to your computer and use it in GitHub Desktop.
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" | |
set :application, '(1)'#Name | |
set :user, '(2)' #User | |
set :use_sudo, false | |
set :repository, '(3)' #Repositorio | |
set :deploy_to, "/home/#{user}/www/#{application}" | |
set :deploy_via, (4) #:remote_cache or :copy | |
set :scm, :git | |
set :branch, 'master' | |
set :git_enable_submodules, true | |
set :keep_releases, 10 | |
set :unicorn_pid, "#{shared_path}/pids/unicorn.pid" | |
role :app, '(5)'#IP | |
role :web, '(6)'#IP | |
role :db, '(7)', :primary => true #IP | |
namespace :deploy do | |
desc "Make symlink for database.yml" | |
task :symlink_dbyaml do | |
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" | |
end | |
desc "Reload the database with seed data" | |
task :seed do | |
run "cd #{current_path}; rake db:seed RAILS_ENV=#{rails_env}" | |
end | |
desc "Make symlink for images" | |
task :symlink_images do | |
run "ln -nfs #{shared_path}/system #{release_path}/public/system" | |
end | |
end | |
namespace :unicorn do | |
task :start, :roles => :app, :except => { :no_release => true} do | |
run "cd #{current_path} && bundle exec unicorn_rails -c #{current_path}/config/unicorn.rb -D -E production" | |
end | |
task :stop, :roles => :app, :except => { :no_release => true} do | |
run "kill `cat #{unicorn_pid}` || true" | |
end | |
task :reload, :roles => :app, :except => { :no_release => true } do | |
run "kill -s USR2 `cat #{unicorn_pid}` || true" | |
end | |
task :restart, :roles => :app, :except => { :no_release => true } do | |
stop | |
start | |
end | |
after "deploy:restart", "unicorn:restart" | |
end | |
desc "Tarefa para criar as configurações do banco em produção" | |
task :create_database_config do | |
configs =<<-EOF | |
production: | |
adapter: mysql2 | |
encoding: utf8 | |
reconnect: false | |
database: (8) | |
pool: 5 | |
username: (9) | |
password: (10) | |
host: localhost | |
EOF | |
run "mkdir -p #{shared_path}/config" | |
put configs, "#{shared_path}/config/database.yml" | |
end | |
task :create_images do | |
run "mkdir -p #{shared_path}/images/system" | |
end | |
after 'deploy:update_code', 'deploy:symlink_dbyaml' | |
after "deploy", "deploy:cleanup" | |
after "deploy", "deploy:symlink_images" | |
after 'deploy:setup', 'create_database_config' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment