capistrano-haproxy 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,4 +18,6 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_dependency("capistrano")
21
+ gem.add_dependency("capistrano-file-resources", "~> 0.0.1")
22
+ gem.add_dependency("capistrano-file-transfer-ext", "~> 0.0.3")
21
23
  end
@@ -1,6 +1,7 @@
1
1
  require "capistrano-haproxy/version"
2
+ require "capistrano/configuration/actions/file_transfer_ext"
3
+ require "capistrano/configuration/resources/file_resources"
2
4
  require "erb"
3
- require "tempfile"
4
5
  require "uri"
5
6
 
6
7
  module Capistrano
@@ -78,7 +79,7 @@ module Capistrano
78
79
  # Do not run automatically during normal `deploy' to avoid slow down.
79
80
  # If you want to do so, add following line in your ./config/deploy.rb
80
81
  #
81
- # after 'deploy:update', 'haproxy:update'
82
+ # after 'deploy:finalize_update', 'haproxy:update'
82
83
 
83
84
  task(:_update, :roles => :app, :except => { :no_release => true }) {
84
85
  configure
@@ -123,42 +124,12 @@ module Capistrano
123
124
  # TODO: setup (sysvinit|daemontools|upstart|runit|systemd) service of HAProxy
124
125
  }
125
126
 
126
- def tempfile(name)
127
- f = Tempfile.new(name)
128
- path = f.path
129
- f.close(true) # close and remove tempfile immediately
130
- path
131
- end
132
-
133
- def template(file)
134
- if File.file?(file)
135
- File.read(file)
136
- elsif File.file?("#{file}.erb")
137
- ERB.new(File.read("#{file}.erb")).result(binding)
138
- else
139
- abort("No such template: #{file} or #{file}.erb")
140
- end
141
- end
142
-
143
127
  _cset(:haproxy_template_path, File.join(File.dirname(__FILE__), 'capistrano-haproxy', 'templates'))
144
128
  _cset(:haproxy_configure_files, %w(/etc/default/haproxy haproxy.cfg))
145
129
  task(:configure, :roles => :app, :except => { :no_release => true }) {
146
- srcs = haproxy_configure_files.map { |file| File.join(haproxy_template_path, file) }
147
- tmps = haproxy_configure_files.map { |file| tempfile('capistrano-haproxy') }
148
- dsts = haproxy_configure_files.map { |file| File.expand_path(file) == file ? file : File.join(haproxy_path, file) }
149
- begin
150
- srcs.zip(tmps) do |src, tmp|
151
- put(template(src), tmp)
152
- end
153
- execute = []
154
- dirs = dsts.map { |path| File.dirname(path) }.uniq
155
- execute << "#{sudo} mkdir -p #{dirs.map { |dir| dir.dump }.join(' ')}" unless dirs.empty?
156
- tmps.zip(dsts) do |tmp, dst|
157
- execute << "( diff -u #{dst.dump} #{tmp.dump} || #{sudo} mv -f #{tmp.dump} #{dst.dump} )"
158
- end
159
- run(execute.join(' && ')) unless execute.empty?
160
- ensure
161
- run("rm -f #{tmps.map { |t| t.dump }.join(' ')}") unless tmps.empty?
130
+ haproxy_configure_files.each do |f|
131
+ safe_put(template(f, :path => haproxy_template_path), ( File.expand_path(f) == f ? f : File.join(haproxy_path, f) ),
132
+ :place => :if_modified, :sudo => true)
162
133
  end
163
134
  }
164
135
 
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module HAProxy
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-haproxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-07 00:00:00.000000000 Z
12
+ date: 2013-02-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
@@ -27,6 +27,38 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: capistrano-file-resources
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.0.1
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.0.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: capistrano-file-transfer-ext
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.0.3
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.3
30
62
  description: a capistrano recipe to setup HAProxy.
31
63
  email:
32
64
  - yamashita@geishatokyo.com