Forks

Revisions

gist: 185481 Download_button fork
public
Description:
Receita simples de Capistrano. É a minha base pra todos os projetos.
Public Clone URL: git://gist.github.com/185481.git
Embed All Files: show embed
deploy.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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"