itrigga-cap_deploy 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/itrigga/cap_deploy.rb +5 -1
- data/lib/itrigga/cap_deploy/cap_tasks.rb +45 -2
- data/lib/itrigga/cap_deploy/filesystem_utils.rb +21 -19
- data/lib/itrigga/cap_deploy/hooks.rb +5 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/itrigga/cap_deploy.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
files = Dir.glob(File.join(File.dirname(__FILE__), 'cap_deploy/**/*') )
|
2
|
+
files.each{|f| require f }
|
3
|
+
|
2
4
|
|
3
5
|
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
4
6
|
Capistrano::Configuration.instance(:must_exist) :
|
5
7
|
Capistrano.configuration(:must_exist)
|
6
8
|
|
7
9
|
configuration.load do
|
8
|
-
|
10
|
+
# have to load this with 'load', not 'require'
|
11
|
+
# because cap configuration has redefined 'load' to instance_eval the loaded file
|
12
|
+
load File.join(File.dirname(__FILE__), 'cap_deploy/filesystem_utils.rb')
|
9
13
|
end
|
@@ -1,4 +1,8 @@
|
|
1
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
2
|
+
Capistrano::Configuration.instance(:must_exist) :
|
3
|
+
Capistrano.configuration(:must_exist)
|
1
4
|
|
5
|
+
configuration.load do
|
2
6
|
def with_role(role, &block)
|
3
7
|
original, ENV['HOSTS'] = ENV['HOSTS'], find_servers(:roles =>role).map{|d| d.host}.join(",")
|
4
8
|
begin
|
@@ -105,6 +109,45 @@
|
|
105
109
|
end
|
106
110
|
|
107
111
|
task :chown_entire_project_dir do
|
108
|
-
puts "chowning entire #{application_stub} dir to #{
|
109
|
-
run "#{sudo} chown -R #{
|
112
|
+
puts "chowning entire #{application_stub} dir to #{user_and_group}"
|
113
|
+
run "#{sudo} chown -R #{user_and_group} #{deploy_to}"
|
110
114
|
end
|
115
|
+
|
116
|
+
task :regenerate_db_scripts do
|
117
|
+
puts "regenerating db scripts"
|
118
|
+
|
119
|
+
run "test -d #{web_dir}/script/db && #{sudo} rm -rf #{web_dir}/script/db/*"
|
120
|
+
run "cd #{web_dir} && ruby script/generate db"
|
121
|
+
|
122
|
+
puts "setting permissions & ownership on cron and db scripts"
|
123
|
+
run "#{sudo} chmod 0700 #{web_dir}/script/db/* && #{sudo} chown root #{web_dir}/script/db/*"
|
124
|
+
end
|
125
|
+
|
126
|
+
task :regenerate_cron_scripts do
|
127
|
+
puts "regenerating cron scripts"
|
128
|
+
|
129
|
+
run "(test -d #{web_dir}/script/cron && #{sudo} rm -rf #{web_dir}/script/cron/*) || echo 'no existing scripts/cron dir'"
|
130
|
+
run "cd #{web_dir} && ruby script/generate cron"
|
131
|
+
|
132
|
+
puts "setting permissions & ownership on cron scripts"
|
133
|
+
run "test -d #{web_dir}/script/cron && #{sudo} find #{web_dir}/script/cron -type f -print | xargs -I{} #{sudo} chown root {} "
|
134
|
+
end
|
135
|
+
|
136
|
+
task :regenerate_monitoring_scripts do
|
137
|
+
puts "regenerating monitoring scripts"
|
138
|
+
run "cd #{web_dir} && ruby script/generate scripting -f"
|
139
|
+
|
140
|
+
puts "setting permissions and ownership for solr_lockfile check script"
|
141
|
+
run "#{sudo} chmod 0700 #{web_dir}/script/monitoring/solr_lockfile_check && #{sudo} chown root #{web_dir}/script/monitoring/solr_lockfile_check"
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
task :symlink_cron_scripts do
|
146
|
+
puts "symlinking any cron scripts in scripts/cron into /etc/cron.d/"
|
147
|
+
|
148
|
+
symlink_files_in_dir("#{web_dir}/script/cron","/etc/cron.d")
|
149
|
+
|
150
|
+
# give cron a kick to pick up the new changes
|
151
|
+
run "#{sudo} service cron reload"
|
152
|
+
end
|
153
|
+
end
|
@@ -1,25 +1,27 @@
|
|
1
|
-
def symlink_dir(from, to)
|
2
|
-
run "test -L #{to} || ( #{sudo} find #{to} -mindepth 1 -print | xargs -i mv {} #{from} && #{sudo} rm -rf #{to} && #{sudo} ln -s #{from} #{to} )"
|
3
|
-
end
|
4
1
|
|
5
|
-
def
|
6
|
-
|
7
|
-
end
|
2
|
+
def symlink_dir(from, to)
|
3
|
+
run "test -L #{to} || ( #{sudo} find #{to} -mindepth 1 -print | xargs -i mv {} #{from} && #{sudo} rm -rf #{to} && #{sudo} ln -s #{from} #{to} )"
|
4
|
+
end
|
8
5
|
|
9
|
-
def
|
10
|
-
|
6
|
+
def delete_files_from_dir1_which_exist_in_dir2(delete_from_dir, exist_in_dir)
|
7
|
+
run "find #{exist_in_dir} -type f | xargs -n1 basename | xargs -I{} bash -c 'test -f #{delete_from_dir}/{} && rm -v #{delete_from_dir}/{} || echo no file #{delete_from_dir}/{} to delete'"
|
8
|
+
end
|
9
|
+
|
10
|
+
def symlink_files_in_dir(from_dir,to_dir)
|
11
|
+
delete_files_from_dir1_which_exist_in_dir2(to_dir, from_dir)
|
11
12
|
|
12
|
-
|
13
|
-
end
|
13
|
+
run "(#{sudo} test -d #{from_dir} && ( find #{from_dir}/ -mindepth 1 -print | xargs --verbose #{sudo} ln -s -f -t #{to_dir} ) ) || echo 'nothing to link'"
|
14
|
+
end
|
14
15
|
|
15
|
-
def mkdir_unless_exists( dir )
|
16
|
-
|
17
|
-
end
|
16
|
+
def mkdir_unless_exists( dir )
|
17
|
+
run "test -d #{dir} || #{sudo} mkdir -p #{dir}"
|
18
|
+
end
|
18
19
|
|
19
|
-
def symlink_dir(from, to)
|
20
|
-
|
21
|
-
end
|
20
|
+
def symlink_dir(from, to)
|
21
|
+
run "test -L #{to} || ( #{sudo} find #{to} -mindepth 1 -print | xargs -i mv {} #{from} && #{sudo} rm -rf #{to} && #{sudo} ln -s #{from} #{to} )"
|
22
|
+
end
|
22
23
|
|
23
|
-
def mkdir_unless_exists( dir )
|
24
|
-
|
25
|
-
end
|
24
|
+
def mkdir_unless_exists( dir )
|
25
|
+
run "test -d #{dir} || #{sudo} mkdir -p #{dir}"
|
26
|
+
end
|
27
|
+
|
@@ -1,4 +1,8 @@
|
|
1
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
2
|
+
Capistrano::Configuration.instance(:must_exist) :
|
3
|
+
Capistrano.configuration(:must_exist)
|
1
4
|
|
5
|
+
configuration.load do
|
2
6
|
after "deploy:setup", :chown_entire_project_dir
|
3
7
|
after "deploy:symlink", :symlink_init_d_script
|
4
8
|
after "deploy:symlink", :symlink_log_dirs
|
@@ -6,3 +10,4 @@
|
|
6
10
|
after "deploy:symlink", :symlink_site_cache_dir
|
7
11
|
# only keep the last 5 releases (otherwise diskspace balloons)
|
8
12
|
after "deploy:update", "deploy:cleanup"
|
13
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itrigga-cap_deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.4
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Al Davidson
|