eureka_ruby 0.0.6 → 0.0.7

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
  SHA256:
3
- metadata.gz: f5a3affd81e8b8ad6adc8b5c37317153a8e6bb5b37430f54f408b8d343b8690d
4
- data.tar.gz: ec9904d73a249ae3a1e3a9489644c884ec30af06e5e94812fa1852eae16c1448
3
+ metadata.gz: c7784c42fe43339752201acf900892cf379bf233b811aaaebc31c1ccddc0ac3b
4
+ data.tar.gz: 3ce81d17b8d152dff01b1a32b42ca51bb0c9b35e33dc3a4340d962a29b811b2a
5
5
  SHA512:
6
- metadata.gz: ec7aff78cac558748d2da4d6d93ec74099c4c6d40f2a7de6913198f80cea8335a2c4b635248a18e40260f6108ed533d9752e752ea18682cb2d082f836da89f97
7
- data.tar.gz: 784b50b37010ef55f43e808e481b7578078905a7f38c9cbbdcead9c3b5dcea6d47d7761ebeacb5671a32da320f50a34c28413b0a2b69e0675751e4ebf444979b
6
+ metadata.gz: b99401c0647e240e7c092f5e93a9f3019f7ce35a478647bd3eef303801b947f297ae4d30607957232b68c7d1bbd39f5bc011bdee102ddf645da031523d7b1f21
7
+ data.tar.gz: 9369ddb6fc827a00af76fcbebeb94d9b6d6bb529b075018b11e6c8bbe860435f25c260e125c57c608347dbc48712489143d84844ef760bd94c1b18194b4e5336
@@ -34,15 +34,18 @@ module EurekaRuby
34
34
 
35
35
  def request(path)
36
36
  response = yield("#{base}#{path}")
37
- return response if [200, 204].include? response.status
38
37
 
39
- raise <<-ERROR
40
- \nEurekaRequestError:
38
+ unless [200, 204].include? response.status
39
+ puts <<-ERROR
40
+ EurekaRequestError:
41
41
  request: #{path}
42
42
  response:
43
43
  status: #{response.status}
44
44
  body: #{response.body}
45
- ERROR
45
+ ERROR
46
+ end
47
+
48
+ response
46
49
  end
47
50
  end
48
51
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EurekaRuby
4
- VERSION = '0.0.6'
4
+ VERSION = '0.0.7'
5
5
  end
@@ -24,13 +24,16 @@ if ENV['EUREKA']
24
24
  # Keep Living
25
25
  Thread.new do
26
26
  loop do
27
- EurekaRuby.executor.run(:send_heartbeat)
28
- rescue => ex
29
- error_text = "发送心跳到 Eureka 失败: #{ex.message}\n#{ex.backtrace.join("\n")}"
27
+ response = EurekaRuby.executor.run(:send_heartbeat)
28
+ next if [200, 204].include? response.status
29
+
30
+ EurekaRuby.executor.run(:register) if response.status == 404
31
+
32
+ error_text = "发送心跳到 Eureka 失败: status: #{response.status} body: #{response.body.to_s}"
30
33
  Rails.logger.error(error_text)
31
34
  NewRelic::Agent.notice_error(error_text) if defined?(NewRelic)
32
35
  ensure
33
- sleep ENV.fetch('EUREKA_HEARTBEAT_PERIOD', 10).to_i
36
+ sleep ENV.fetch('EUREKA_HEARTBEAT_PERIOD', 5).to_i
34
37
  end
35
38
  end
36
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eureka_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - 乌托邦科技
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-20 00:00:00.000000000 Z
11
+ date: 2019-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler