capistrano-toolbox 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,7 +27,7 @@ Capistrano::Configuration.instance(:must_exist).load do
27
27
  end
28
28
  end
29
29
 
30
- def remote_file_exists?(path)
31
- 'true' == capture("test -f #{path} && echo true || echo false").strip
30
+ def remote_file_exists?(path, options={})
31
+ 'true' == capture("test -f #{path} && echo true || echo false", options).strip
32
32
  end
33
33
  end
@@ -4,30 +4,37 @@ Capistrano::Configuration.instance(:must_exist).load do
4
4
  namespace :deploy do
5
5
  namespace :unicorn do
6
6
  task :restart, :roles => :app, :except => { :no_release => true } do
7
- old_pid = nil
8
- if remote_file_exists?(unicorn_pid)
9
- old_pid = capture("cat #{unicorn_pid}")
10
- cmd = "kill -s USR2 #{old_pid}"
11
- else
12
- cmd = "RAILS_ENV=production /etc/init.d/unicorn start"
13
- end
7
+ servers = find_servers roles: :app
8
+ servers.each do |server|
9
+ old_pid = nil
10
+ if remote_file_exists?(unicorn_pid, hosts: [server])
11
+ old_pid = capture("cat #{unicorn_pid}", hosts: [server])
12
+ cmd = "kill -s USR2 #{old_pid}"
13
+ else
14
+ cmd = "RAILS_ENV=production /etc/init.d/unicorn start"
15
+ end
14
16
 
15
- run cmd, :shell => '/bin/bash'
17
+ run(cmd, shell: '/bin/bash', hosts: [server])
16
18
 
17
- sleep(1)
18
- cmd = <<-SHELL
19
- echo -n " Waiting for unicorn" ; while [ ! -s #{unicorn_pid} -o -s #{unicorn_pid}.oldbin ] ; do echo -n "." ; sleep 1 ; done
20
- SHELL
21
- run(cmd, shell: '/bin/bash') do |channel, stream, data|
22
- print(data)
23
- end
19
+ sleep(1)
20
+
21
+ cmd = "echo -n ' Waiting for unicorn' ; while [ ! -s #{
22
+ unicorn_pid
23
+ } -o -s #{
24
+ unicorn_pid
25
+ }.oldbin ] ; do echo -n '.' ; sleep 1 ; done"
26
+
27
+ run(cmd, shell: '/bin/bash', hosts: [server]) do |channel, stream, data|
28
+ print(data)
29
+ end
24
30
 
25
- new_pid = capture("cat #{unicorn_pid}")
31
+ new_pid = capture("cat #{unicorn_pid}", hosts: [server])
26
32
 
27
- if new_pid == old_pid
28
- raise "Unicorn failed to restart!"
33
+ if new_pid == old_pid
34
+ raise "Unicorn failed to restart!"
35
+ end
29
36
  end
30
37
  end
31
38
  end
32
39
  end
33
- end
40
+ 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.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: