Create a gist now

Instantly share code, notes, and snippets.

Receita simples de Capistrano. É a minha base pra todos os projetos.
set :application, "myapp"
set :keep_releases, 5
# git options
set :scm, "git"
set :repository, "git://github.com/georgeguimaraes/myapp.git"
set :branch, "master"
set :deploy_via, :remote_cache
# deploy credentials
set :user, "deploy"
set :deploy_to, "/home/deploy/#{application}"
set :use_sudo, false
# server definitions
set :servers, "example.com"
role :app, servers
role :web, servers
role :db, servers, :primary => true
default_run_options[:pty] = true
# working with Passenger
namespace :deploy do
desc "Restarting mod_rails with restart.txt"
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{current_path}/tmp/restart.txt"
end
[:start, :stop].each do |t|
desc "don't need #{t} task with mod_rails"
task t, :roles => :app do
run "touch #{current_path}/tmp/restart.txt"
end
end
end
desc "Link in the production database.yml"
task :after_update_code do
run "ln -nfs #{deploy_to}/#{shared_dir}/config/database.yml #{release_path}/config/database.yml"
end
# Only runs this task after deploy:setup
# Used to create a new config/database.yml which differs from the repository
namespace :init do
desc "Create production-only database.yml"
task :production_database_yml do
database_configuration =<<-EOF
production:
adapter: mysql
encoding: utf8
reconnect: false
database: #{application}_production
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock
EOF
run "mkdir -p #{shared_path}/config"
put database_configuration, "#{shared_path}/config/database.yml"
end
end
after "deploy:setup", "init:production_database_yml"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment