eye 0.9.pre → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e50d71e8909ed2df73bede83562f4254f374fa99
4
- data.tar.gz: 2328cd9e596a36e42763514bf9c09190f7e7dc36
3
+ metadata.gz: b76b8d9060cb42b041484705984a1a7f3da93b38
4
+ data.tar.gz: ca3823da4f96ff0935b83687a1c1ef06716a1fbe
5
5
  SHA512:
6
- metadata.gz: 675c027af39891e72aa31101cdcc18eeeeb3f8e5b04e7ef56e67e88a49f6e703efaf8301a9f8c8aa9d0d20c3c6467b5c172e6e9e9b4b5b39c850b2789d52e314
7
- data.tar.gz: 2b5f93e6d191f4f65d560f54d46ffef5ba95b555f4d3911509ed9828645e9d877813864f938b5dab7aa3c85ef9ae8374583bf19987c9120447f81d55dc11721a
6
+ metadata.gz: 10f87c6c0916bd8384d736c23673821c4e9ba06af76ae51293e95b451319bfec6dfe9fac50aec8903cc26679143e2b2fcd47352ade2132efdbe4d656de3a65ac
7
+ data.tar.gz: 36bded5d52f33ff52ee0908bb16fe57c5a0afab6d8d608138fd2b398b3deb3212f4772f2c26598c6c667a81a0969e05520b39225e69955ba3ae75e618c780eac
@@ -77,6 +77,9 @@ Style/PercentLiteralDelimiters:
77
77
  Metrics/LineLength:
78
78
  Max: 142
79
79
 
80
+ Metrics/BlockLength:
81
+ Max: 50
82
+
80
83
  Metrics/PerceivedComplexity:
81
84
  Max: 15
82
85
  Exclude:
data/CHANGES.md CHANGED
@@ -1,3 +1,13 @@
1
+ 0.9.1
2
+ -------
3
+ * fix client protocol compatibility with old server
4
+
5
+ 0.9
6
+ -------
7
+ * replace old gem state_machine, to state_machines
8
+ * rewrite internal scheduler for chains
9
+ * change client-server protocol (recommend to quit server and up after update gem)
10
+
1
11
  0.8.1
2
12
  -------
3
13
  * allow matching many apps when mask started with '*' (#169)
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Eye::Trigger::FixCrash < Eye::Trigger::Custom
4
4
 
5
- param :times, Fixnum, nil, 1
5
+ param :times, Integer, nil, 1
6
6
  param_default :to, :up
7
7
 
8
8
  def check(_)
@@ -45,7 +45,7 @@ Eye.app :triggers do
45
45
  daemonize true
46
46
 
47
47
  app_name = app.name
48
- trigger :transition, event: :restarting, do: ->{
48
+ trigger :transition, event: :restarting, do: -> {
49
49
  info 'send restarting to :a'
50
50
  Eye::Control.command('restart', "#{app_name}:a")
51
51
  }
data/lib/eye.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Eye
2
- VERSION = '0.9.pre'
2
+ VERSION = '0.9.1'
3
3
  ABOUT = "Eye v#{VERSION} (c) 2012-2016 @kostya"
4
4
  PROCLINE = "eye monitoring v#{VERSION}"
5
5
 
@@ -23,10 +23,10 @@ class Eye::Checker
23
23
 
24
24
  attr_accessor :value, :values, :options, :pid, :type, :check_count, :process
25
25
 
26
- param :every, [Fixnum, Float], false, 5
27
- param :times, [Fixnum, Array], nil, 1
26
+ param :every, [Integer, Float], false, 5
27
+ param :times, [Integer, Array], nil, 1
28
28
  param :fires, [Symbol, Array, Proc], nil, nil, [:stop, :restart, :unmonitor, :start, :delete, :nothing, :notify]
29
- param :initial_grace, [Fixnum, Float]
29
+ param :initial_grace, [Integer, Float]
30
30
  param :skip_initial_fails, [TrueClass, FalseClass]
31
31
 
32
32
  def self.name_and_class(type)
@@ -253,8 +253,8 @@ class Eye::Checker
253
253
 
254
254
  class Measure < Eye::Checker
255
255
 
256
- param :below, [Fixnum, Float]
257
- param :above, [Fixnum, Float]
256
+ param :below, [Integer, Float]
257
+ param :above, [Integer, Float]
258
258
 
259
259
  def good?(value)
260
260
  return false if below && (value > below)
@@ -8,10 +8,10 @@ class Eye::Checker::Http < Eye::Checker::Defer
8
8
  param :url, String, true
9
9
  param :proxy_url, String
10
10
  param :pattern, [String, Regexp]
11
- param :kind, [String, Fixnum, Symbol]
12
- param :timeout, [Fixnum, Float]
13
- param :open_timeout, [Fixnum, Float]
14
- param :read_timeout, [Fixnum, Float]
11
+ param :kind, [String, Integer, Symbol]
12
+ param :timeout, [Integer, Float]
13
+ param :open_timeout, [Integer, Float]
14
+ param :read_timeout, [Integer, Float]
15
15
 
16
16
  attr_reader :uri
17
17
 
@@ -21,7 +21,7 @@ class Eye::Checker::Http < Eye::Checker::Defer
21
21
  @uri = URI.parse(url)
22
22
  @proxy_uri = URI.parse(proxy_url) if proxy_url
23
23
  @kind = case kind
24
- when Fixnum then Net::HTTPResponse::CODE_TO_OBJ[kind.to_s]
24
+ when Integer then Net::HTTPResponse::CODE_TO_OBJ[kind.to_s]
25
25
  when String, Symbol then Net.const_get("HTTP#{kind.to_s.camelize}") rescue Net::HTTPSuccess
26
26
  else Net::HTTPSuccess
27
27
  end
@@ -13,9 +13,9 @@ class Eye::Checker::Socket < Eye::Checker::Defer
13
13
  # :protocol way of pack,unpack messages (default = socket default), example: :protocol => :em_object
14
14
 
15
15
  param :addr, String, true
16
- param :timeout, [Fixnum, Float]
17
- param :open_timeout, [Fixnum, Float]
18
- param :read_timeout, [Fixnum, Float]
16
+ param :timeout, [Integer, Float]
17
+ param :open_timeout, [Integer, Float]
18
+ param :read_timeout, [Integer, Float]
19
19
  param :send_data
20
20
  param :expect_data, [String, Regexp, Proc]
21
21
  param :protocol, [Symbol], nil, nil, [:default, :em_object, :raw]
@@ -5,13 +5,20 @@ class Eye::Client
5
5
 
6
6
  attr_reader :socket_path
7
7
 
8
- def initialize(socket_path)
8
+ def initialize(socket_path, type = :old)
9
9
  @socket_path = socket_path
10
+ @type = type
10
11
  end
11
12
 
13
+ SIGN = 123_566_983
14
+
12
15
  def execute(h = {})
13
- payload = Marshal.dump(h)
14
- payload = payload.length.to_s + "\n" + payload
16
+ payload = if @type == :old
17
+ Marshal.dump([h[:command], *h[:args]]) # TODO: remove in 1.0
18
+ else
19
+ payload = Marshal.dump(h)
20
+ [SIGN, payload.length].pack('N*') + payload
21
+ end
15
22
  timeout = h[:timeout] || Eye::Local.client_timeout
16
23
  attempt_command(payload, timeout)
17
24
  end
@@ -1,6 +1,6 @@
1
1
  class Eye::Dsl::ConfigOpts < Eye::Dsl::PureOpts
2
2
 
3
- create_options_methods([:logger_level], Fixnum)
3
+ create_options_methods([:logger_level], Integer)
4
4
  create_options_methods([:http], Hash)
5
5
 
6
6
  def logger(*args)
@@ -11,10 +11,10 @@ class Eye::Dsl::Opts < Eye::Dsl::PureOpts
11
11
  INTERVAL_OPTIONS = [:check_alive_period, :start_timeout, :restart_timeout, :stop_timeout, :start_grace,
12
12
  :restart_grace, :stop_grace, :children_update_period, :restore_in,
13
13
  :auto_update_pidfile_grace, :revert_fuckup_pidfile_grace, :check_identity_period, :check_identity_grace].freeze
14
- create_options_methods(INTERVAL_OPTIONS, [Fixnum, Float])
14
+ create_options_methods(INTERVAL_OPTIONS, [Integer, Float])
15
15
 
16
16
  create_options_methods([:environment], Hash)
17
- create_options_methods([:umask], Fixnum)
17
+ create_options_methods([:umask], Integer)
18
18
 
19
19
  def initialize(name = nil, parent = nil)
20
20
  super(name, parent)
@@ -212,12 +212,12 @@ private
212
212
  while s.present?
213
213
  sig = s.shift
214
214
  timeout = s.shift
215
- if sig && ![String, Symbol, Fixnum].include?(sig.class)
215
+ if sig && !([String, Symbol].include?(sig.class) || sig.is_a?(Integer))
216
216
  raise Eye::Dsl::Error, "signal should be String, Symbol, Fixnum, not #{sig.inspect}"
217
217
  end
218
218
 
219
- if timeout && ![Fixnum, Float].include?(timeout.class)
220
- raise Eye::Dsl::Error, "signal sleep should be Numeric, not #{timeout.inspect}"
219
+ if timeout && !timeout.is_a?(Numeric)
220
+ raise Eye::Dsl::Error, "signal sleep should be Numeric, not #{timeout.inspect} - #{timeout.class}"
221
221
  end
222
222
  end
223
223
  end
@@ -8,7 +8,7 @@ class Eye::Notify::Jabber < Eye::Notify
8
8
  # end
9
9
 
10
10
  param :host, String, true
11
- param :port, [String, Fixnum], true
11
+ param :port, [String, Integer], true
12
12
  param :user, String, true
13
13
  param :password, String
14
14
 
@@ -8,7 +8,7 @@ class Eye::Notify::Mail < Eye::Notify
8
8
  # end
9
9
 
10
10
  param :host, String, true
11
- param :port, [String, Fixnum], true
11
+ param :port, [String, Integer], true
12
12
 
13
13
  param :domain, String
14
14
  param :user, String
@@ -34,9 +34,10 @@ class Eye::Server
34
34
  rescue
35
35
  # new format
36
36
  begin
37
- pos = text.index("\n")
38
- msg_size = text[0..pos].to_i
39
- content = text[pos + 1..-1]
37
+ sign, msg_size = text[0...8].unpack('N*')
38
+ raise "unknown protocol #{sign}" unless sign == Eye::Client::SIGN
39
+ msg_size = text[4...8].unpack('N')[0]
40
+ content = text[8..-1]
40
41
  content << socket.read(msg_size - content.length) while content.length < msg_size
41
42
  payload = Marshal.load(content)
42
43
  cmd = payload[:command]
@@ -3,12 +3,12 @@ class Eye::Trigger::Flapping < Eye::Trigger
3
3
  # trigger :flapping, :times => 10, :within => 1.minute,
4
4
  # :retry_in => 10.minutes, :retry_times => 15
5
5
 
6
- param :times, [Fixnum], true, 5
7
- param :within, [Float, Fixnum], true
8
- param :retry_in, [Float, Fixnum]
9
- param :retry_times, [Fixnum]
10
- param :reretry_in, [Float, Fixnum]
11
- param :reretry_times, [Fixnum]
6
+ param :times, [Integer], true, 5
7
+ param :within, [Float, Integer], true
8
+ param :retry_in, [Float, Integer]
9
+ param :retry_times, [Integer]
10
+ param :reretry_in, [Float, Integer]
11
+ param :reretry_times, [Integer]
12
12
 
13
13
  def initialize(*args)
14
14
  super
@@ -6,10 +6,10 @@ class Eye::Trigger::StartingGuard < Eye::Trigger
6
6
  #
7
7
  # trigger :starting_guard, every: 10.seconds, should: ->{ `cat /tmp/bla` == "bla" }
8
8
 
9
- param :every, [Float, Fixnum], false, 10
10
- param :times, [Fixnum]
11
- param :retry_in, [Float, Fixnum]
12
- param :retry_times, [Fixnum]
9
+ param :every, [Float, Integer], false, 10
10
+ param :times, [Integer]
11
+ param :retry_in, [Float, Integer]
12
+ param :retry_times, [Integer]
13
13
  param :should, [Proc, Symbol]
14
14
 
15
15
  def initialize(*args)
@@ -4,7 +4,7 @@ class Eye::Trigger::StopChildren < Eye::Trigger
4
4
  #
5
5
  # trigger :stop_children
6
6
 
7
- param :timeout, [Fixnum, Float], nil, 60
7
+ param :timeout, [Integer, Float], nil, 60
8
8
 
9
9
  # default on stopped, crashed
10
10
  param_default :event, [:stopped, :crashed]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eye
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.pre
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Makarchev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-05 00:00:00.000000000 Z
11
+ date: 2016-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid
@@ -469,7 +469,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
469
469
  version: 1.3.6
470
470
  requirements: []
471
471
  rubyforge_project:
472
- rubygems_version: 2.4.7
472
+ rubygems_version: 2.6.6
473
473
  signing_key:
474
474
  specification_version: 4
475
475
  summary: Process monitoring tool. Inspired from Bluepill and God. Requires Ruby(MRI)