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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/fast_git_deploy/recipes/fast_git_deploy/setup.rb', line 3
def self.load_into(configuration)
configuration.load do
namespace :deploy do
namespace :fast_git_setup do
task :cold do
clone_repository
finalize_clone
create_revision_log
deploy.update
deploy.start
end
def self.clone_repository_command(path)
[
"if [ ! -e #{path} ]",
"then mkdir -p #{deploy_to}",
"cd #{deploy_to}",
"#{scm_command} clone #{repository} #{path}",
"fi"
].join("; ")
end
desc "Clones the repos"
task :clone_repository, :except => { :no_release => true } do
run clone_repository_command(current_path)
end
task :create_revision_log, :except => { :no_release => true } do
run [
"if [ ! -e #{revision_log} ]",
"then touch #{revision_log}",
"chmod 664 #{revision_log}",
"fi"
].join("; ")
end
task :warm do
clone_repository_to_tmp_path
deploy.web.disable
remove_old_app
rename_clone
finalize_clone
deploy.default
deploy.web.enable
end
task :clone_repository_to_tmp_path, :except => { :no_release => true } do
run clone_repository_command("#{current_path}.clone")
end
task :rename_clone, :except => { :no_release => true } do
run "mv #{current_path}.clone #{current_path}"
end
task :remove_old_app do
remove_releases
remove_current
end
task :remove_releases, :except => { :no_release => true } do
run [
"if [ -e #{deploy_to}/releases ]",
"then mv #{deploy_to}/releases #{deploy_to}/releases.old",
"fi"
].join("; ")
end
task :remove_current, :except => { :no_release => true } do
run [
"if [ -h #{current_path} ]",
"then mv #{current_path} #{current_path}.old",
"fi"
].join("; ")
end
desc <<-HERE
This task will make the release group-writable (if the :group_writable
variable is set to true, which is the default). It will then set up
symlinks to the shared directory for the log, system, and tmp/pids
directories.
HERE
task :finalize_clone, :except => { :no_release => true } do
run "chmod -R g+w #{current_path}" if fetch(:group_writable, true)
run [
"rm -rf #{current_path}/log #{current_path}/public/system #{current_path}/tmp/pids",
"mkdir -p #{current_path}/public",
"mkdir -p #{current_path}/tmp",
"ln -s #{shared_path}/log #{current_path}/log",
"ln -s #{shared_path}/system #{current_path}/public/system",
"ln -s #{shared_path}/tmp/pids #{current_path}/tmp/pids"
].join(" && ")
end
end
end
end
end
|