little-dutch 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f38c1fbad6eece05731ce41b91890c1495df942f
4
- data.tar.gz: 065b27f61804b8b7889cd85deaf7762774d44997
3
+ metadata.gz: 97ee749c6b2850b9efd6d388d0f38d4ed10875b4
4
+ data.tar.gz: 867bcd2717a1887eee00e9b1fb25b1c716de2b6a
5
5
  SHA512:
6
- metadata.gz: 28507530f0316e008743a6389e9c37f28fce0a15dc1f159eb129d001ac4fb2692feb8a884bf70b16c60f81ca1a3c8ffa4f049a83fc936edd19b1b415e37df11e
7
- data.tar.gz: 92804645e98810ef9927c455cb83bc6a04c35f96839612fdeb952d05b6900ff1411ec98c4c490efa46152a13a4e065f3a929bef690c5d95e9ab363276e7d229b
6
+ metadata.gz: dd10af110d1360b8327764f8f5c73edeeec306a24a407a60642ef6e48c745f70c9a778ccfa334aa04aec3e4a42deb04aeafdcc824623a356acf133fcf9eb09f6
7
+ data.tar.gz: 71ceb93354c055c29f82eacde2f1ade9b72ac7b99338afeb5a8e1c5993ce4a1e872eaa32393918c1d91dc5440acb222167f611fcdf0fc1963073c49e85a6838a
data/lib/little-dutch.rb CHANGED
@@ -26,13 +26,24 @@ module LittleDutch
26
26
  @runner.try(:kill)
27
27
  end
28
28
 
29
+ def profile_instance?
30
+ url = URI.parse(config.endpoint)
31
+ url.path = "/r/#{config.app_name}/#{config.instance_id}"
32
+ url.query = { token: config.token }.to_param
33
+ Faraday.get(url).status == 200
34
+ rescue Faraday::ConnectionFailed
35
+ false
36
+ end
37
+
29
38
  private
30
39
 
31
40
  def run_loop
32
41
  @runcount = 0
33
42
  loop do
34
- @runcount += 1
35
- post_json ObjectSpace.dump_all
43
+ if profile_instance?
44
+ @runcount += 1
45
+ post_json ObjectSpace.dump_all
46
+ end
36
47
  sleep config.interval
37
48
  end
38
49
  end
@@ -49,9 +60,9 @@ module LittleDutch
49
60
  url = URI.parse(config.endpoint)
50
61
  url.path = "/r/#{config.app_name}/#{config.instance_id}/#{@runcount}"
51
62
  url.query = { token: config.token }.to_param
52
- path = file.tap(&:close).path
63
+ file_path = file.tap(&:close).path
53
64
  curl_cmd = <<-SHELL.lines.map(&:strip).join(' ; ')
54
- curl -X POST --retry 10 -H "Transfer-Encoding: chunked" -H "Content-Type: application/text" --data-binary @#{path} #{url.to_s}
65
+ curl -X POST --retry 10 -H "Transfer-Encoding: chunked" -H "Content-Type: application/text" --data-binary @#{file_path} #{url.to_s}
55
66
  rm -f #{file}
56
67
  SHELL
57
68
  Process.spawn curl_cmd, out: config.logfile, err: config.logfile, in: '/dev/null'
@@ -1,5 +1,5 @@
1
1
  module Little
2
2
  module Dutch
3
- VERSION = "0.0.11"
3
+ VERSION = "0.0.12"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: little-dutch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Waldrip