ruby-quilt 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/quilt.rb +27 -10
  2. metadata +2 -2
data/lib/quilt.rb CHANGED
@@ -188,16 +188,15 @@ class Quilt
188
188
  filename = "#{name}.tgz"
189
189
  version_dir = File.join(@config[:local_path], name)
190
190
  begin
191
- Net::HTTP.start(@config[:remote_host].to_s, port) do |http|
192
- res = http.get(File.join(@config[:remote_path].to_s, "#{name}.tgz"))
193
- if (res.code != "200")
194
- log_error("no version fetched : #{res.code}")
195
- return nil
196
- end
197
- FileUtils.mkdir(version_dir) unless File.exists?(version_dir)
198
- open(File.join(version_dir, filename), "wb") do |file|
199
- file.write(res.body)
200
- end
191
+ res = Net::HTTP.get_response(@config[:remote_host].to_s,
192
+ File.join(@config[:remote_path].to_s, "#{name}.tgz"), port)
193
+ if (res.code != "200")
194
+ log_error("no version fetched : #{res.code}")
195
+ return nil
196
+ end
197
+ FileUtils.mkdir(version_dir) unless File.exists?(version_dir)
198
+ open(File.join(version_dir, filename), "wb") do |file|
199
+ file.write(res.body)
201
200
  end
202
201
  rescue Exception => e
203
202
  log_error("could not fetch version", e)
@@ -260,4 +259,22 @@ class Quilt
260
259
  outversion[:footer] :
261
260
  ''}"
262
261
  end
262
+
263
+ def healthy?
264
+ # return true if no remote info
265
+ return [true, nil] if !@config[:remote_host] || !@config[:remote_path]
266
+ # fetch health_check.txt from remote URL
267
+ host = @config[:remote_host].to_s
268
+ port = @config[:remote_port] ? @config[:remote_port].to_i : 80
269
+ path = File.join(@config[:remote_path].to_s, 'health_check.txt')
270
+ begin
271
+ res = Net::HTTP.get_response(host, path, port)
272
+ if (res.code != "200")
273
+ return [false, "Could not fetch heath check file: http://#{host}:#{port}#{path} - status #{res.code}"]
274
+ end
275
+ rescue Exception => e
276
+ return [false, "Could not fetch heath check file: http://#{host}:#{port}#{path} - #{e.message}"]
277
+ end
278
+ [true, nil]
279
+ end
263
280
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-quilt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
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-04-26 00:00:00.000000000 Z
12
+ date: 2012-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json