capistrano-lemur 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/capistrano-lemur.gemspec +1 -1
- data/lib/capistrano/lemur/db.rb +9 -7
- data/lib/capistrano/lemur/mysql.rb +12 -30
- data/lib/capistrano/lemur/nginx.rb +80 -12
- data/lib/capistrano/lemur/unicorn.rb +10 -31
- data/lib/capistrano-lemur/version.rb +1 -1
- metadata +5 -7
- data/lib/capistrano/lemur/bundler.rb +0 -14
- data/lib/capistrano/lemur/outage.rb +0 -70
data/capistrano-lemur.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["jorbabe@gmail.com"]
|
7
7
|
gem.description = %q{Recipes for deploying a LEMUR (Linux/Nginx/Mysql/Unicorn/Rails) stack. Some of it is pulled from an existing application}
|
8
8
|
gem.summary = %q{Collection of Capistrano recipes for deploying a LEMUR (Linux/Nginx/Mysql/Unicorn/Rails) stack}
|
9
|
-
gem.homepage = "https://github.com/
|
9
|
+
gem.homepage = "https://github.com/amaabca/capistrano-lemur"
|
10
10
|
|
11
11
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
12
|
gem.files = `git ls-files`.split("\n")
|
data/lib/capistrano/lemur/db.rb
CHANGED
@@ -4,38 +4,38 @@ Capistrano::Configuration.instance.load do
|
|
4
4
|
|
5
5
|
namespace :db do
|
6
6
|
desc "LMR Setup application schema"
|
7
|
-
task :setup do
|
7
|
+
task :setup, :roles => :db, :only => {:primary => true}, :except => { :no_release => true } do
|
8
8
|
run "cd #{current_path}; bundle exec rake RAILS_ENV=#{rails_env} db:create"
|
9
9
|
end
|
10
10
|
|
11
11
|
desc "LMR Export the database into the db/ folder"
|
12
|
-
task :backup, :only => {:primary => true}, :except => { :no_release => true } do
|
12
|
+
task :backup, :roles => :db, :only => {:primary => true}, :except => { :no_release => true } do
|
13
13
|
run "cd #{current_path}; bundle exec rake RAILS_ENV=#{rails_env} db:data:backup"
|
14
14
|
end
|
15
15
|
|
16
16
|
desc "LMR Export the database into the db/ folder"
|
17
|
-
task :restore, :only => {:primary => true}, :except => { :no_release => true } do
|
17
|
+
task :restore, :roles => :db, :only => {:primary => true}, :except => { :no_release => true } do
|
18
18
|
confirm = Capistrano::CLI.ui.ask "This is a dangerous task. Type 'yes sir' to continue."
|
19
19
|
exit unless confirm.downcase == 'yes sir'
|
20
20
|
run "cd #{current_path}; bundle exec rake RAILS_ENV=#{rails_env} db:data:restore"
|
21
21
|
end
|
22
22
|
|
23
23
|
desc "LMR Export the database into the db/ folder"
|
24
|
-
task :restore_from_staging, :only => {:primary => true}, :except => { :no_release => true } do
|
24
|
+
task :restore_from_staging, :roles => :db, :only => {:primary => true}, :except => { :no_release => true } do
|
25
25
|
confirm = Capistrano::CLI.ui.ask "This is a dangerous task. Type 'yes sir' to continue."
|
26
26
|
exit unless confirm.downcase == 'yes sir'
|
27
27
|
run "cd #{current_path}; bundle exec rake RAILS_ENV=#{rails_env} db:data:restore_from_staging"
|
28
28
|
end
|
29
29
|
|
30
30
|
desc "LMR Export the database into the db/ folder"
|
31
|
-
task :restore_from_production, :only => {:primary => true}, :except => { :no_release => true } do
|
31
|
+
task :restore_from_production, :roles => :db, :only => {:primary => true}, :except => { :no_release => true } do
|
32
32
|
confirm = Capistrano::CLI.ui.ask "This is a dangerous task. Type 'yes sir' to continue."
|
33
33
|
exit unless confirm.downcase == 'yes sir'
|
34
34
|
run "cd #{current_path}; bundle exec rake RAILS_ENV=#{rails_env} db:data:restore_from_production"
|
35
35
|
end
|
36
36
|
|
37
37
|
desc "LMR Wipe tables then rerun all migrations and seed database"
|
38
|
-
task :remigrate, :only => {:primary => true}, :except => { :no_release => true } do
|
38
|
+
task :remigrate, :roles => :db, :only => {:primary => true}, :except => { :no_release => true } do
|
39
39
|
confirm = Capistrano::CLI.ui.ask "This is a dangerous task. Type 'yes sir' to continue."
|
40
40
|
exit unless confirm.downcase == 'yes sir'
|
41
41
|
backup
|
@@ -43,12 +43,14 @@ Capistrano::Configuration.instance.load do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
desc "Seed the database on already deployed code"
|
46
|
-
task :seed, :only => {:primary => true}, :except => { :no_release => true } do
|
46
|
+
task :seed, :roles => :db, :only => {:primary => true}, :except => { :no_release => true } do
|
47
47
|
confirm = Capistrano::CLI.ui.ask "This is a dangerous task. Type 'yes sir' to continue."
|
48
48
|
exit unless confirm.downcase == 'yes sir'
|
49
49
|
run "cd #{current_path}; bundle exec rake RAILS_ENV=#{rails_env} db:seed"
|
50
50
|
end
|
51
51
|
|
52
|
+
after "mysql:create_users", "db:setup"
|
53
|
+
|
52
54
|
end
|
53
55
|
|
54
56
|
|
@@ -2,24 +2,22 @@ Capistrano::Configuration.instance.load do
|
|
2
2
|
|
3
3
|
namespace :mysql do
|
4
4
|
|
5
|
-
desc "LMR Create default db and user.
|
6
|
-
task :create_users, :roles => :db, :except => { :no_release => true } do
|
5
|
+
desc "LMR Create default db and user."
|
6
|
+
task :create_users, :roles => :db, :only => {:primary => true}, :except => { :no_release => true } do
|
7
7
|
|
8
8
|
db_config = YAML::load_file("config/database.yml")
|
9
9
|
db_user = db_config[rails_env.to_s]["username"]
|
10
10
|
db_password = db_config[rails_env.to_s]["password"]
|
11
11
|
db_name = db_config[rails_env.to_s]["database"]
|
12
|
-
|
13
|
-
|
14
|
-
db_root_password
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
|
13
|
+
db_root_password = Capistrano::CLI.password_prompt("Mysql root user password (blank to use value created by Chef run)?")
|
14
|
+
if db_root_password.to_s.length == 0
|
15
|
+
sudo "ls -al" #So we don't get prompted on the line below.....
|
16
|
+
db_root_password = capture("sudo cat /var/cache/local/preseeding/mysql-server.seed").split(" ")[3]
|
17
|
+
puts "Use this password #{db_root_password} "
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
fetch(:mysql_server, roles[:app].collect {|r| r.host} + ["localhost"]).each do |server|
|
23
21
|
check_user = capture("mysql --user=root -p#{db_root_password} -B -N -e \"select count(*) from mysql.user where host = '#{server}' and user = '#{db_user}';\"").chomp.to_i
|
24
22
|
run "mysql --user=root -p#{db_root_password} -e \"CREATE USER '#{db_user}'@'#{server}' IDENTIFIED BY '#{db_password}'\"" unless check_user == 1
|
25
23
|
run "mysql --user=root -p#{db_root_password} -e \"GRANT CREATE ON *.* TO '#{db_user}'@'#{server}'\""
|
@@ -29,24 +27,8 @@ Capistrano::Configuration.instance.load do
|
|
29
27
|
|
30
28
|
end
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
run "cd #{current_path}; bundle exec rake RAILS_ENV=#{rails_env} db:create"
|
35
|
-
end
|
36
|
-
|
37
|
-
desc "LMR db:migration"
|
38
|
-
task :migrate, :only => {:primary => true}, :except => { :no_release => true } do
|
39
|
-
run "cd #{current_path}; bundle exec rake RAILS_ENV=#{rails_env} db:migrate"
|
40
|
-
end
|
41
|
-
|
42
|
-
desc "LMR seed the database on already deployed code"
|
43
|
-
task :seed, :only => {:primary => true}, :except => { :no_release => true } do
|
44
|
-
confirm = Capistrano::CLI.ui.ask "This is a dangerous task. Type Y to continue."
|
45
|
-
exit unless confirm.downcase == 'y'
|
46
|
-
run "cd #{current_path}; bundle exec rake RAILS_ENV=#{rails_env} db:seed"
|
47
|
-
end
|
48
|
-
|
49
|
-
|
30
|
+
before "deploy:cold", "mysql:create_users"
|
31
|
+
|
50
32
|
end
|
51
33
|
|
52
34
|
end
|
@@ -1,8 +1,13 @@
|
|
1
1
|
Capistrano::Configuration.instance.load do
|
2
2
|
namespace :nginx do
|
3
3
|
|
4
|
-
set(:nginx_path)
|
5
|
-
set(:nginx_cmd)
|
4
|
+
set(:nginx_path) { "/etc/nginx" }
|
5
|
+
set(:nginx_cmd) { "/etc/init.d/nginx" }
|
6
|
+
set(:nginx_ports) { Array("80") }
|
7
|
+
|
8
|
+
set(:nginx_server_names) {
|
9
|
+
find_servers(:roles => :web).collect {|s| s.host}
|
10
|
+
}
|
6
11
|
|
7
12
|
desc "LMR Copy application nginx config into sites-available and symlink into sites-enabled"
|
8
13
|
task :setup, :roles => :web do
|
@@ -11,7 +16,7 @@ Capistrano::Configuration.instance.load do
|
|
11
16
|
location = Capistrano::CLI.ui.ask "Filename of nginx config file (blank for default of config/nginx.#{stage})?"
|
12
17
|
location = "nginx.#{stage}" if location.nil? or location.length < 1
|
13
18
|
# Backup the old config and copy app config
|
14
|
-
run "cp #{nginx_path}/sites-available/#{application} #{nginx_path}/sites-available/#{application}.#{Time.now.strftime("%Y%m%
|
19
|
+
run "cp #{nginx_path}/sites-available/#{application} #{nginx_path}/sites-available/#{application}.#{Time.now.strftime("%Y%m%dT%H%M%S")} && cp #{current_path}/config/#{location} #{nginx_path}/sites-available/#{application}"
|
15
20
|
run "if [ ! -L #{nginx_path}/sites-enabled/#{application} ]; then ln -s #{nginx_path}/sites-available/#{application} #{nginx_path}/sites-enabled/#{application}; fi"
|
16
21
|
else
|
17
22
|
puts "Nginx configuration change aborted"
|
@@ -19,35 +24,98 @@ Capistrano::Configuration.instance.load do
|
|
19
24
|
end
|
20
25
|
end
|
21
26
|
|
27
|
+
desc "Generate Nginx virtual host file"
|
28
|
+
task :generate_config, :roles => :web do
|
29
|
+
confirm = Capistrano::CLI.ui.ask "This is a dangerous task. Type 'yes sir' to continue."
|
30
|
+
if confirm.downcase == 'yes sir'
|
31
|
+
config_file = ERB.new(fetch(:nginx_erb_template)).result(binding)
|
32
|
+
put config_file, "#{nginx_path}/sites-available/#{application}"
|
33
|
+
run "if [ ! -L /etc/nginx/sites-enabled/#{application} ]; then ln -s /etc/nginx/sites-available/#{application} /etc/nginx/sites-enabled/#{application}; fi"
|
34
|
+
else
|
35
|
+
puts "Nginx configuration change aborted"
|
36
|
+
exit
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
22
40
|
task :test_config, :roles => :web do
|
23
41
|
sudo "#{nginx_cmd} configtest"
|
24
42
|
end
|
25
43
|
|
26
44
|
desc "LMR Restart only primary node"
|
27
45
|
task :restart_primary, :roles => :web, :only => {:primary => true} do
|
28
|
-
|
46
|
+
restart_nginx
|
29
47
|
end
|
30
48
|
|
31
49
|
desc "LMR Restart only secondary node"
|
32
50
|
task :restart_secondary, :roles => :web, :except => {:primary => true} do
|
33
|
-
|
51
|
+
restart_nginx
|
34
52
|
end
|
35
53
|
|
36
54
|
desc "LMR Restart all Nginx nodes"
|
37
|
-
task :
|
38
|
-
|
55
|
+
task :restart, :roles => :web do
|
56
|
+
restart_nginx
|
39
57
|
end
|
40
58
|
|
41
|
-
|
42
|
-
|
43
|
-
confirm = Capistrano::CLI.ui.ask "This is a dangerous task. Type 'yes sir' to continue."
|
44
|
-
if confirm.downcase == "yes sir"
|
59
|
+
def restart_nginx
|
60
|
+
if Capistrano::CLI.ui.ask("This is a dangerous task. Type 'yes sir' to continue.") == "yes sir"
|
45
61
|
sudo "#{nginx_cmd} restart"
|
46
62
|
else
|
47
63
|
puts "Restart aborted"
|
48
|
-
exit
|
49
64
|
end
|
50
65
|
end
|
51
66
|
|
52
67
|
end
|
68
|
+
|
69
|
+
set(:nginx_erb_template) do
|
70
|
+
<<-NGINX
|
71
|
+
upstream <%= application.to_s %> {
|
72
|
+
server unix:<%= unicorn_target.to_s %>/tmp/sockets/unicorn.sock fail_timeout=0;
|
73
|
+
}
|
74
|
+
|
75
|
+
server {
|
76
|
+
listen <%= nginx_ports.join(" ") %>;
|
77
|
+
server_name <%= nginx_server_names.join(" ") %>;
|
78
|
+
|
79
|
+
root <%= current_path.to_s %>/public;
|
80
|
+
|
81
|
+
rewrite_log on;
|
82
|
+
|
83
|
+
access_log /var/log/nginx/<%= application.to_s %>-access.log combined;
|
84
|
+
error_log /var/log/nginx/<%= application.to_s %>-error.log;
|
85
|
+
|
86
|
+
location / {
|
87
|
+
#all requests are sent to the UNIX socket
|
88
|
+
proxy_pass http://<%= application.to_s %>;
|
89
|
+
proxy_redirect off;
|
90
|
+
|
91
|
+
proxy_set_header Host $host;
|
92
|
+
proxy_set_header X-Real-IP $remote_addr;
|
93
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
94
|
+
|
95
|
+
client_max_body_size 10m;
|
96
|
+
client_body_buffer_size 128k;
|
97
|
+
|
98
|
+
proxy_connect_timeout 90;
|
99
|
+
proxy_send_timeout 90;
|
100
|
+
proxy_read_timeout 90;
|
101
|
+
|
102
|
+
proxy_buffer_size 4k;
|
103
|
+
proxy_buffers 4 32k;
|
104
|
+
proxy_busy_buffers_size 64k;
|
105
|
+
proxy_temp_file_write_size 64k;
|
106
|
+
}
|
107
|
+
|
108
|
+
# if the request is for a static resource, nginx should serve it directly
|
109
|
+
# and add a far future expires header to it, making the browser
|
110
|
+
# cache the resource and navigate faster over the website
|
111
|
+
# this probably needs some work with Rails 3.1's asset pipe_line
|
112
|
+
location ~ ^/(images|javascripts|stylesheets|system)/ {
|
113
|
+
root <%= current_path.to_s %>/public;
|
114
|
+
expires max;
|
115
|
+
break;
|
116
|
+
}
|
117
|
+
}
|
118
|
+
NGINX
|
119
|
+
end
|
120
|
+
|
53
121
|
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
Capistrano::Configuration.instance.load do
|
2
|
+
|
3
|
+
set(:unicorn_target) { current_path }
|
2
4
|
|
3
5
|
# TODO: make this more generic once we start using in multiple apps
|
4
6
|
namespace :deploy do
|
@@ -6,44 +8,21 @@ Capistrano::Configuration.instance.load do
|
|
6
8
|
# override default tasks to make capistrano happy
|
7
9
|
desc "LMR Start unicorn"
|
8
10
|
task :start, :roles => :app do
|
9
|
-
|
10
|
-
start_secondary unless (find_servers :roles => :app, :except => {:primary => true}).empty?
|
11
|
-
|
12
|
-
|
13
|
-
desc "LMR Start unicorn on primary server"
|
14
|
-
task :start_primary, :roles => :app, :only => { :primary => true } do
|
15
|
-
run "cd #{current_path} && server=primary bundle exec unicorn -c #{current_path}/config/unicorn.rb -E #{rails_env} -D"
|
16
|
-
end
|
17
|
-
|
18
|
-
desc "LMR Start unicorn on secondary server(s)"
|
19
|
-
task :start_secondary, :roles => :app, :except => { :primary => true } do
|
20
|
-
run "cd #{current_path} && server=secondary bundle exec unicorn -c #{current_path}/config/unicorn.rb -E #{rails_env} -D"
|
21
|
-
end
|
22
|
-
|
23
|
-
desc "LMR Start unicorn on primary server"
|
24
|
-
task :stop_primary, :roles => :app, :only => { :primary => true } do
|
25
|
-
run "kill -QUIT `cat #{current_path}/tmp/pids/unicorn.pid`"
|
26
|
-
sleep 2
|
27
|
-
start_primary
|
28
|
-
end
|
29
|
-
|
30
|
-
desc "LMR Start unicorn on secondary server(s)"
|
31
|
-
task :stop_secondary, :roles => :app, :except => { :primary => true } do
|
32
|
-
run "kill -QUIT `cat #{current_path}/tmp/pids/unicorn.pid`"
|
33
|
-
sleep 2
|
34
|
-
start_secondary
|
11
|
+
#start_primary
|
12
|
+
#start_secondary unless (find_servers :roles => :app, :except => {:primary => true}).empty?
|
13
|
+
run "cd #{current_path} && bundle exec unicorn -c #{unicorn_target}/config/unicorn.rb -E #{rails_env} -D"
|
35
14
|
end
|
36
15
|
|
37
16
|
desc "LMR Kick unicorn"
|
38
17
|
task :restart, :roles => :app do
|
39
|
-
run "kill -USR2 `cat #{
|
18
|
+
run "kill -USR2 `cat #{unicorn_target}/tmp/pids/unicorn.pid`"
|
40
19
|
end
|
41
20
|
|
42
21
|
desc "LMR Kill a unicorn"
|
43
22
|
task :stop, :roles => :app do
|
44
|
-
run "kill -QUIT `cat #{
|
23
|
+
run "kill -QUIT `cat #{unicorn_target}/tmp/pids/unicorn.pid`"
|
45
24
|
end
|
46
|
-
|
47
|
-
|
48
|
-
|
25
|
+
|
26
|
+
end
|
27
|
+
|
49
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-lemur
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-03-05 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
16
|
-
requirement: &
|
16
|
+
requirement: &2158299140 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 2.11.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2158299140
|
25
25
|
description: Recipes for deploying a LEMUR (Linux/Nginx/Mysql/Unicorn/Rails) stack.
|
26
26
|
Some of it is pulled from an existing application
|
27
27
|
email:
|
@@ -39,14 +39,12 @@ files:
|
|
39
39
|
- lib/capistrano-lemur.rb
|
40
40
|
- lib/capistrano-lemur/version.rb
|
41
41
|
- lib/capistrano/lemur/all.rb
|
42
|
-
- lib/capistrano/lemur/bundler.rb
|
43
42
|
- lib/capistrano/lemur/db.rb
|
44
43
|
- lib/capistrano/lemur/filesystem.rb
|
45
44
|
- lib/capistrano/lemur/mysql.rb
|
46
45
|
- lib/capistrano/lemur/nginx.rb
|
47
|
-
- lib/capistrano/lemur/outage.rb
|
48
46
|
- lib/capistrano/lemur/unicorn.rb
|
49
|
-
homepage: https://github.com/
|
47
|
+
homepage: https://github.com/amaabca/capistrano-lemur
|
50
48
|
licenses: []
|
51
49
|
post_install_message:
|
52
50
|
rdoc_options: []
|
@@ -1,14 +0,0 @@
|
|
1
|
-
Capistrano::Configuration.instance.load do
|
2
|
-
namespace :bundler do
|
3
|
-
task :create_symlink, :roles => :app do
|
4
|
-
shared_dir = File.join(shared_path, 'bundle')
|
5
|
-
release_dir = File.join(current_release, '.bundle')
|
6
|
-
run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{release_dir}")
|
7
|
-
end
|
8
|
-
|
9
|
-
task :bundle_new_release, :roles => :app do
|
10
|
-
#bundler.create_symlink
|
11
|
-
run "cd #{current_path} && bundle install --deployment --quiet --without development test cucumber"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'capistrano'
|
2
|
-
|
3
|
-
# TODO: use the built in Capistrano web:disable by setting:
|
4
|
-
# maintenance_basename (path to html)
|
5
|
-
# maintenance_template_path (path to erb)
|
6
|
-
|
7
|
-
module Capistrano::Lemur::Outage
|
8
|
-
def self.load_into(configuration)
|
9
|
-
configuration.load do
|
10
|
-
|
11
|
-
set(:outage_templates) { ["membership_outage.html","registration_outage.html"] }
|
12
|
-
|
13
|
-
|
14
|
-
namespace :web do
|
15
|
-
|
16
|
-
desc "LMR Serve up a custom maintenance page."
|
17
|
-
task :disable, :roles => :web do
|
18
|
-
Capistrano::Lemur::Outage.disable_template
|
19
|
-
end
|
20
|
-
|
21
|
-
desc "LMR Remove a custom maintenance page."
|
22
|
-
task :enable, :roles => :web do
|
23
|
-
Capistrano::Lemur::Outage.enable_template
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
namespace :membership do
|
29
|
-
|
30
|
-
desc "LMR Serve up a custom maintenance page."
|
31
|
-
task :disable, :roles => :web do
|
32
|
-
Capistrano::Lemur::Outage.disable_template(outage_templates)
|
33
|
-
end
|
34
|
-
|
35
|
-
desc "LMR Remove a custom maintenance page."
|
36
|
-
task :enable, :roles => :web do
|
37
|
-
Capistrano::Lemur::Outage.enable_template(outage_templates)
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
def self.enable_template(templates = Array("maintenance.html") )
|
47
|
-
templates.each do |template|
|
48
|
-
require 'erb'
|
49
|
-
on_rollback { run "rm #{current_path}/public/system/#{template}" }
|
50
|
-
|
51
|
-
reason = ENV['REASON']
|
52
|
-
deadline = ENV['UNTIL']
|
53
|
-
|
54
|
-
file = File.read(File.join("app/views/system/#{template}.erb"))
|
55
|
-
page = ERB.new(file).result(binding)
|
56
|
-
put(page, "#{current_path}/public/system/#{template}", :mode => 0644)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.disable_template(templates = Array("maintenance.html") )
|
61
|
-
templates.each do |template|
|
62
|
-
run "rm #{current_path}/public/system/#{template}"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
if Capistrano::Configuration.instance
|
69
|
-
Capistrano::Lemur::Outage.load_into(Capistrano::Configuration.instance)
|
70
|
-
end
|