capistrano-toolbox 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/capistrano-toolbox/helpers.rb +12 -8
- data/lib/capistrano-toolbox/nginx.rb +14 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24946192ec201ff25510b07b39f5787b9bb96205
|
4
|
+
data.tar.gz: 81d97deeb0549e641ce8873d997fc60b709ecba6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 869f8a6603a1108e530c854a7c9600635cc0c2caa3563fa44dc5f98f1546ec24e67076a8a668026eabb7f0cf5f66ce17ffaf02566dc2b16c6c5182c01916df34
|
7
|
+
data.tar.gz: 38c10ecd1430ba3a2420d0c76442ae26eb8f0ce43f31ce030b2fcc428a6500b2c1e3bb0692413114330af5607fc202ebc28548f281963419a54a2d9d2c0a215d
|
@@ -1,34 +1,38 @@
|
|
1
1
|
require 'securerandom'
|
2
2
|
|
3
3
|
Capistrano::Configuration.instance(:must_exist).load do
|
4
|
-
def
|
4
|
+
def put_nginx_config (user, contents, target, sudo=false)
|
5
5
|
tempfile = Tempfile.new(File.basename(target))
|
6
6
|
tempfile.write(contents)
|
7
7
|
tempfile.close
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
|
9
|
+
remote_tempfile ="#{release_path}/tmp/new-nginx-config"
|
10
|
+
restart_nginx_file = "#{release_path}/tmp/nginx_restart.txt"
|
11
|
+
|
12
|
+
suscp(user, tempfile.path, remote_tempfile, sudo)
|
13
|
+
surun(user, "diff -q #{remote_tempfile} #{target} && rm #{remote_tempfile} || (mv #{remote_tempfile} #{target} && touch #{restart_nginx_file})", sudo)
|
14
|
+
surun(user, "chmod 644 #{target} && chown root:root #{target}", sudo)
|
11
15
|
tempfile.unlink
|
12
16
|
end
|
13
17
|
|
14
18
|
def suscp (user, from, to, sudo=false)
|
15
19
|
servers = find_servers_for_task(current_task)
|
16
20
|
servers.each do |server|
|
17
|
-
|
18
|
-
command = "scp #{from} #{user}@#{server}:#{tempfile}"
|
21
|
+
command = "scp #{from} #{user}@#{server}:#{to}"
|
19
22
|
puts " * \033[1;33mexecuting \"#{command}\"\033[0m"
|
20
23
|
raise unless system command
|
21
|
-
surun(user, "mv #{tempfile} #{to}", sudo)
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
27
|
+
|
25
28
|
def surun (user, command, sudo=false)
|
26
29
|
puts " * \033[1;33mexecuting sudo \"#{command}\"\033[0m"
|
27
30
|
servers = find_servers_for_task(current_task)
|
28
31
|
puts " servers: #{servers.inspect}"
|
29
32
|
servers.each do |server|
|
30
33
|
puts " [#{server}] executing command"
|
31
|
-
|
34
|
+
maybe_sudo = sudo ? "sudo -s /bin/bash -c #{command.inspect}" : command
|
35
|
+
raise unless system %!ssh #{server} -l #{user} #{maybe_sudo.inspect}!
|
32
36
|
end
|
33
37
|
end
|
34
38
|
|
@@ -13,16 +13,19 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
13
13
|
config = fetch(:nginx_config, nil)
|
14
14
|
if config
|
15
15
|
available_path = File.join(config_dir, "#{application}.conf")
|
16
|
-
|
16
|
+
put_nginx_config(nginx_user, config, available_path, nginx_use_sudo)
|
17
17
|
surun(nginx_user, "nxensite #{application}.conf", nginx_use_sudo)
|
18
18
|
end
|
19
19
|
|
20
20
|
ssl_config = fetch(:nginx_ssl_config, nil)
|
21
21
|
if ssl_config
|
22
22
|
available_ssl_path = File.join(config_dir, "#{application}-ssl.conf")
|
23
|
-
|
23
|
+
put_nginx_config(nginx_user, ssl_config, available_ssl_path, nginx_use_sudo)
|
24
24
|
surun(nginx_user, "nxensite #{application}-ssl.conf", nginx_use_sudo)
|
25
25
|
end
|
26
|
+
|
27
|
+
restart_nginx = "#{release_path}/tmp/nginx_restart.txt"
|
28
|
+
surun(nginx_user, "! test -f #{restart_nginx} || service nginx reload", nginx_use_sudo)
|
26
29
|
end
|
27
30
|
|
28
31
|
desc "Reload nginx config"
|
@@ -32,8 +35,15 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
32
35
|
|
33
36
|
surun(nginx_user, "service nginx reload", nginx_use_sudo)
|
34
37
|
end
|
38
|
+
|
39
|
+
desc "Restart nginx"
|
40
|
+
task :restart, :roles => :app, :except => { :no_release => true } do
|
41
|
+
nginx_user = fetch(:nginx_user, "root")
|
42
|
+
nginx_use_sudo = fetch(:nginx_use_sudo, false)
|
43
|
+
|
44
|
+
surun(nginx_user, "service nginx restart", nginx_use_sudo)
|
45
|
+
end
|
46
|
+
|
35
47
|
end
|
36
48
|
end
|
37
|
-
|
38
|
-
after "deploy:nginx:update_config", "deploy:nginx:reload"
|
39
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Louis Giordano
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-09-
|
13
|
+
date: 2013-09-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: capistrano
|