squirrel-eycap 0.4.10 → 0.4.12
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/lib/eycap.rb +1 -1
- data/lib/eycap/recipes/database.rb +4 -7
- data/lib/eycap/recipes/mongrel.rb +30 -2
- data/lib/eycap/recipes/nginx.rb +2 -2
- metadata +1 -1
data/History.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.4.12 / 2009-06-26
|
2
|
+
* removed condition for dbhost that was useless and tested db:clone_prod_to_staging
|
3
|
+
|
4
|
+
== 0.4.11 / 2009-06-25
|
5
|
+
* changed nginx start and restart to give output to cap
|
6
|
+
* fixed db:clone_to_local task
|
7
|
+
|
1
8
|
== 0.4.10 / 2009-06-24
|
2
9
|
* using nohup on nginx start and restart
|
3
10
|
|
data/lib/eycap.rb
CHANGED
@@ -21,7 +21,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
21
21
|
|
22
22
|
if @environment_info['adapter'] == 'mysql'
|
23
23
|
dbhost = @environment_info['host']
|
24
|
-
dbhost = environment_dbhost.sub('-master', '') + '-replica'
|
24
|
+
dbhost = environment_dbhost.sub('-master', '') + '-replica'
|
25
25
|
run "mysqldump --add-drop-table -u #{dbuser} -h #{dbhost} -p #{environment_database} | bzip2 -c > #{backup_file}.bz2" do |ch, stream, out |
|
26
26
|
ch.send_data "#{dbpass}\n" if out=~ /^Enter password:/
|
27
27
|
end
|
@@ -63,14 +63,11 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
63
63
|
get "#{backup_file}.bz2", "/tmp/#{application}.sql.gz"
|
64
64
|
development_info = YAML.load_file("config/database.yml")['development']
|
65
65
|
if development_info['adapter'] == 'mysql'
|
66
|
-
|
67
|
-
ch.send_data "#{development_info['password']}\n" if out=~ /Enter password:/
|
68
|
-
end
|
66
|
+
run_str = "bzcat /tmp/#{application}.sql.gz | mysql -u #{development_info['username']} --password='#{development_info['password']}' -h #{development_info['host']} #{development_info['database']}"
|
69
67
|
else
|
70
|
-
|
71
|
-
ch.send_data "#{development_info['password']}\n" if out=~ /^Password/
|
72
|
-
end
|
68
|
+
run_str = "PGPASSWORD=#{development_info['password']} bzcat /tmp/#{application}.sql.gz | psql -U #{development_info['username']} -h #{development_info['host']} #{development_info['database']}"
|
73
69
|
end
|
70
|
+
%x!#{run_str}!
|
74
71
|
end
|
75
72
|
end
|
76
73
|
|
@@ -24,5 +24,33 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
24
24
|
task :stop, :roles => [:app], :except => {:mongrel => false} do
|
25
25
|
sudo "/usr/bin/monit stop all -g #{monit_group}"
|
26
26
|
end
|
27
|
-
|
28
|
-
|
27
|
+
|
28
|
+
desc <<-DESC
|
29
|
+
Start mongrels in a loop, with a defer of [default] 30 seconds between each single mongrel restart.
|
30
|
+
DESC
|
31
|
+
task :rolling_restart, :roles => [:app], :except => {:mongrel => false} do
|
32
|
+
|
33
|
+
set :mongrel_restart_delay, 30
|
34
|
+
|
35
|
+
# need a script due to weird escapes run by sudo "X".
|
36
|
+
script = File.open("/tmp/rolling.reboot", 'w+')
|
37
|
+
script.puts "#!/bin/bash"
|
38
|
+
script.puts "export monit_group=#{monit_group}"
|
39
|
+
script.puts "export mongrel_restart_delay=#{mongrel_restart_delay}"
|
40
|
+
# here's the need for single quoted - sed ? - (no escaping).
|
41
|
+
script.puts 'for port in $(monit summary | grep mongrel | sed -r \'s/[^0-9]*([0-9]+).*/\1/\'); do echo "Executing monit restart mongrel_${monit_group}_${port}"; /usr/bin/monit restart mongrel_${monit_group}_${port}; echo "sleeping $mongrel_restart_delay"; sleep ${mongrel_restart_delay}; done'
|
42
|
+
script.close
|
43
|
+
|
44
|
+
upload(script.path, script.path, :via=> :scp)
|
45
|
+
|
46
|
+
#it's in the script, on the remote server, execute it.
|
47
|
+
sudo "chmod +x #{script.path}"
|
48
|
+
sudo "#{script.path}"
|
49
|
+
#cleanup
|
50
|
+
sudo "rm #{script.path}"
|
51
|
+
require 'fileutils' ; FileUtils.rm(script.path)
|
52
|
+
puts "Done."
|
53
|
+
end
|
54
|
+
|
55
|
+
end #namespace
|
56
|
+
end #Capistrano::Configuration
|
data/lib/eycap/recipes/nginx.rb
CHANGED
@@ -3,12 +3,12 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
3
3
|
namespace :nginx do
|
4
4
|
desc "Start Nginx on the app slices."
|
5
5
|
task :start, :roles => :app do
|
6
|
-
sudo "nohup /etc/init.d/nginx start
|
6
|
+
sudo "nohup /etc/init.d/nginx start 2>&1 | cat"
|
7
7
|
end
|
8
8
|
|
9
9
|
desc "Restart the Nginx processes on the app slices."
|
10
10
|
task :restart , :roles => :app do
|
11
|
-
sudo "nohup /etc/init.d/nginx restart
|
11
|
+
sudo "nohup /etc/init.d/nginx restart 2>&1 | cat"
|
12
12
|
end
|
13
13
|
|
14
14
|
desc "Stop the Nginx processes on the app slices."
|