/
deploy_rb.erb
70 lines (49 loc) · 1.84 KB
/
deploy_rb.erb
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
66
67
68
69
# -*- encoding : utf-8 -*-
require "./config/boot"
require "bundler/capistrano"
default_environment["PATH"] = "/opt/ruby/bin:/usr/local/bin:/usr/bin:/bin"
set :application, "<%= app_name %>"
set :repository, "git@github.com:example/#{application}.git"
set :deploy_to, "/home/apps/#{application}"
set :branch, "master"
set :scm, :git
set :user, "apps"
set :group, "apps"
set :deploy_to, "/home/apps/#{application}"
set :runner, "apps"
set :deploy_via, :remote_cache
set :git_shallow_clone, 1
role :web, "<%= app_name %>.com" # Your HTTP server, Apache/etc
role :app, "<%= app_name %>.com" # This may be the same as your `Web` server
role :db, "<%= app_name %>.com" , :primary => true # This is where Rails migrations will run
set :deploy_env, "production"
set :rails_env, "production"
set :scm_verbose, true
set :use_sudo, false
namespace :deploy do
desc "Restart passenger process"
task :restart, :roles => [:web], :except => { :no_release => true } do
run "touch #{current_path}/tmp/restart.txt"
end
end
namespace :my_tasks do
task :symlink, :roles => [:web] do
run "mkdir -p #{deploy_to}/shared/log"
run "mkdir -p #{deploy_to}/shared/pids"
symlink_hash = {
"#{shared_path}/config/database.yml" => "#{release_path}/config/database.yml",
"#{shared_path}/config/s3.yml" => "#{release_path}/config/s3.yml",
"#{shared_path}/uploads" => "#{release_path}/public/uploads",
}
symlink_hash.each do |source, target|
run "ln -sf #{source} #{target}"
end
end
end
namespace :remote_rake do
desc "Run a task on remote servers, ex: cap staging rake:invoke task=cache:clear"
task :invoke do
run "cd #{deploy_to}/current; RAILS_ENV=#{rails_env} bundle exec rake #{ENV['task']}"
end
end
after "deploy:finalize_update", "my_tasks:symlink"