capistrano-toolbox 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,4 +26,8 @@ Capistrano::Configuration.instance(:must_exist).load do
26
26
  `ssh #{server} -l root "#{command.gsub('"','\\"')}"`
27
27
  end
28
28
  end
29
+
30
+ def remote_file_exists?(path)
31
+ 'true' == capture("test -f #{path} && echo true").strip
32
+ end
29
33
  end
@@ -4,11 +4,30 @@ 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
- cmd = "if [ -f #{unicorn_pid} ]; then kill -s USR2 `cat #{unicorn_pid}` ; else /etc/init.d/unicorn start ; fi"
8
- # Not specifying a shell would make it run with rvm-shell which would make "unicorn start" loop forever:
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
14
+
9
15
  run cmd, :shell => '/bin/bash'
16
+
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
24
+
25
+ new_pid = capture("cat #{unicorn_pid}")
26
+
27
+ if new_pid == old_pid
28
+ raise "Unicorn failed to restart!"
29
+ end
10
30
  end
11
31
  end
12
32
  end
13
-
14
33
  end
metadata CHANGED
@@ -1,82 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: capistrano-toolbox
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 3
9
- version: 0.0.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Jean-Louis Giordano
13
9
  - Magnus Rex
10
+ - Petter Remen
14
11
  autorequire:
15
12
  bindir: bin
16
13
  cert_chain: []
17
-
18
- date: 2012-06-25 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
14
+ date: 2012-06-26 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
22
17
  name: capistrano
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
25
19
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- segments:
30
- - 0
31
- version: "0"
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
23
+ version: '0'
32
24
  type: :runtime
33
- version_requirements: *id001
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
34
32
  description: Some useful capistrano tools, such as unicorn restart, nginx config etc.
35
33
  email: dev@spnab.com
36
34
  executables: []
37
-
38
35
  extensions: []
39
-
40
36
  extra_rdoc_files: []
41
-
42
- files:
37
+ files:
43
38
  - lib/capistrano-toolbox.rb
44
39
  - lib/capistrano-toolbox/check.rb
45
40
  - lib/capistrano-toolbox/config.rb
46
41
  - lib/capistrano-toolbox/nginx.rb
47
42
  - lib/capistrano-toolbox/unicorn.rb
48
43
  - lib/capistrano-toolbox/helpers.rb
49
- has_rdoc: true
50
44
  homepage: http://github.com/spnab/
51
45
  licenses: []
52
-
53
46
  post_install_message:
54
47
  rdoc_options: []
55
-
56
- require_paths:
48
+ require_paths:
57
49
  - lib
58
- required_ruby_version: !ruby/object:Gem::Requirement
50
+ required_ruby_version: !ruby/object:Gem::Requirement
59
51
  none: false
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- segments:
64
- - 0
65
- version: "0"
66
- required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
57
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- segments:
72
- - 0
73
- version: "0"
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
74
62
  requirements: []
75
-
76
63
  rubyforge_project:
77
- rubygems_version: 1.3.7
64
+ rubygems_version: 1.8.24
78
65
  signing_key:
79
66
  specification_version: 3
80
67
  summary: Some useful capistrano tools.
81
68
  test_files: []
82
-