eye 0.8.rc → 0.8

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: c82745fa85f30eae42687f61dde6724bd5ed1bcd
4
- data.tar.gz: cf600cf41608a73e8512cc0dedc885c63509a2c8
3
+ metadata.gz: 881c3139243423bac750f9b13715f7a17a05703b
4
+ data.tar.gz: 1cfb74cc03c6a05a70df392a5a7871868167e9ec
5
5
  SHA512:
6
- metadata.gz: b6e01c90b2c7b1d3eef6cc6b7eda39aa29a6601b994b9c33897a81e2cb41a11356e00389ec1252aeb1f2295d3f950250a6216ab50abe768cd9a469cf7f24eb6e
7
- data.tar.gz: 0e07121c4ef3fe34eac78a2b82b736ff298dcb7912df26506838ccc14aa0c5f020a9aa9a275adecbd6109181a6941704d4ac0ef007c960a9682512b6ad3ea7a2
6
+ metadata.gz: e4e6b73614e4dc6dd54afb12324f15eb31850f9bb0acce786b4f677f63e313a806155afa523b9e10760743a24a2066f7ab948d8872cd039bffb62f74113bf227
7
+ data.tar.gz: 75b41b0387f461bf333064e98b869c25279dd73c5911778f95ffc00374fcf5639a6a5d90af0a2fd1a3ceca7e602673570e8cf77e475e760e26dc2b053b432235
data/CHANGES.md CHANGED
@@ -1,6 +1,10 @@
1
- 0.8.pre
1
+ 0.8
2
2
  -------
3
- * Update Celluloid to 0.17.0
3
+ * info, xinfo, oinfo, history now support -j flag, to output json
4
+ * leye: many fixes (--eyehome, --eyefile)
5
+ * add flapping reretry_in (#152)
6
+ * add check_identity of processes, avoid many bugs with wrong pid_files, or auto changed pids (#62)
7
+ * update Celluloid to 0.17
4
8
 
5
9
  0.7
6
10
  -------
@@ -17,7 +21,7 @@
17
21
  * some fixes in flapping
18
22
  * add proxy_url to http check
19
23
  * process with children, shows children history now
20
- * Update Celluloid to 0.16.0
24
+ * update Celluloid to 0.16
21
25
 
22
26
  0.6.4
23
27
  -----
data/lib/eye.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Eye
2
- VERSION = '0.8.rc'
2
+ VERSION = '0.8'
3
3
  ABOUT = "Eye v#{VERSION} (c) 2012-2015 @kostya"
4
4
  PROCLINE = "eye monitoring v#{VERSION}"
5
5
 
@@ -97,11 +97,13 @@ class Eye::Checker
97
97
  end
98
98
 
99
99
  def check
100
- if initial_grace && (Time.now - @initialized_at < initial_grace)
101
- debug { 'skipped initial grace' }
102
- return true
103
- else
104
- @options[:initial_grace] = nil
100
+ if initial_grace
101
+ if Time.now - @initialized_at < initial_grace
102
+ debug { 'skipped initial grace' }
103
+ return true
104
+ else
105
+ @options[:initial_grace] = nil
106
+ end
105
107
  end
106
108
 
107
109
  @value = get_value_safe
@@ -124,7 +126,7 @@ class Eye::Checker
124
126
  end
125
127
  end
126
128
 
127
- info "#{last_human_values} => #{result ? 'OK' : 'Fail'}"
129
+ info { "#{last_human_values} => #{result ? 'OK' : 'Fail'}" }
128
130
  result
129
131
 
130
132
  rescue Object => ex
@@ -32,39 +32,40 @@ class Eye::Config
32
32
 
33
33
  # raise an error if config wrong
34
34
  def validate!(validate_apps = [])
35
- all_processes = processes
36
-
37
35
  # Check blank pid_files
38
- no_pid_file = all_processes.select { |c| c[:pid_file].blank? }
39
- if no_pid_file.present?
36
+ no_pid_file = []
37
+ each_process { |c| no_pid_file << c if c[:pid_file].blank? }
38
+ if no_pid_file.any?
40
39
  raise Eye::Dsl::Error, "blank pid_file for: #{no_pid_file.map { |c| c[:name] } * ', '}"
41
40
  end
42
41
 
43
42
  # Check duplicates of the full pid_file
44
43
 
45
- dupl_pids = all_processes.each_with_object(Hash.new(0)) do |o, h|
44
+ dupl_pids = Hash.new(0)
45
+ each_process do |o|
46
46
  ex_pid_file = Eye::System.normalized_file(o[:pid_file], o[:working_dir])
47
- h[ex_pid_file] += 1
47
+ dupl_pids[ex_pid_file] += 1
48
48
  end
49
49
  dupl_pids = dupl_pids.select { |_, v| v > 1 }
50
50
 
51
- if dupl_pids.present?
51
+ if dupl_pids.any?
52
52
  raise Eye::Dsl::Error, "duplicate pid_files: #{dupl_pids.inspect}"
53
53
  end
54
54
 
55
55
  # Check duplicates of the full_name
56
- dupl_names = all_processes.each_with_object(Hash.new(0)) do |o, h|
56
+ dupl_names = Hash.new(0)
57
+ each_process do |o|
57
58
  full_name = "#{o[:application]}:#{o[:group]}:#{o[:name]}"
58
- h[full_name] += 1
59
+ dupl_names[full_name] += 1
59
60
  end
60
61
  dupl_names = dupl_names.select { |_, v| v > 1 }
61
62
 
62
- if dupl_names.present?
63
+ if dupl_names.any?
63
64
  raise Eye::Dsl::Error, "duplicate names: #{dupl_names.inspect}"
64
65
  end
65
66
 
66
67
  # validate processes with their own validate
67
- all_processes.each do |process_cfg|
68
+ each_process do |process_cfg|
68
69
  Eye::Process.validate process_cfg, validate_apps.include?(process_cfg[:application])
69
70
  end
70
71
 
@@ -73,10 +74,8 @@ class Eye::Config
73
74
  end
74
75
 
75
76
  def transform!
76
- all_processes = processes
77
-
78
77
  # transform syslog option
79
- all_processes.each do |process|
78
+ each_process do |process|
80
79
  out = process[:stdout] && process[:stdout].start_with?(':syslog')
81
80
  err = process[:stderr] && process[:stderr].start_with?(':syslog')
82
81
  next unless err || out
@@ -95,8 +94,12 @@ class Eye::Config
95
94
  end
96
95
  end
97
96
 
98
- def processes
99
- applications.values.map { |e| (e[:groups] || {}).values.map { |c| (c[:processes] || {}).values } }.flatten
97
+ def each_process(&block)
98
+ applications.each_value do |app_cfg|
99
+ (app_cfg[:groups] || {}).each_value do |gr_cfg|
100
+ (gr_cfg[:processes] || {}).each_value(&block)
101
+ end
102
+ end
100
103
  end
101
104
 
102
105
  def application_names
@@ -1,4 +1,4 @@
1
- require 'celluloid'
1
+ require 'celluloid/current'
2
2
  require 'yaml'
3
3
 
4
4
  require_relative 'utils/pmap'
@@ -78,11 +78,7 @@ private
78
78
  # return: result, config
79
79
  def parse_config(filename)
80
80
  debug { "parsing: #{filename}" }
81
-
82
- cfg = Eye::Dsl.parse(nil, filename)
83
- @current_config.merge(cfg).validate! # just validate summary config here
84
- Eye.parsed_config = nil # remove link on config, for better gc
85
- cfg
81
+ Eye::Dsl.parse(nil, filename)
86
82
  end
87
83
 
88
84
  # !!! exclusive operation
@@ -37,7 +37,9 @@ class Eye::Dsl
37
37
 
38
38
  Eye.parsed_config.transform!
39
39
  Eye.parsed_config.validate!
40
- Eye.parsed_config
40
+ parsed_config = Eye.parsed_config
41
+ Eye.parsed_config = nil # remove object for better GC
42
+ parsed_config
41
43
  end
42
44
 
43
45
  def parse_apps(*args)
@@ -61,9 +61,7 @@ module Eye::Process::System
61
61
  end
62
62
 
63
63
  def process_pid_running?(pid)
64
- res = Eye::System.check_pid_alive(pid)
65
- debug { "process_really_running?: <#{pid}> #{res.inspect}" }
66
- !!res[:result]
64
+ Eye::System.pid_alive?(pid)
67
65
  end
68
66
 
69
67
  def send_signal(code)
@@ -25,8 +25,12 @@ module Eye::System
25
25
  # very fast
26
26
  # return true/false
27
27
  def pid_alive?(pid)
28
- res = check_pid_alive(pid)
29
- !!res[:result]
28
+ if pid
29
+ ::Process.kill(0, pid)
30
+ true
31
+ end
32
+ rescue
33
+ false
30
34
  end
31
35
 
32
36
  # Send signal to process (uses for kill)
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.8.rc
4
+ version: '0.8'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Makarchev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-18 00:00:00.000000000 Z
11
+ date: 2015-11-22 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.4.5
473
473
  signing_key:
474
474
  specification_version: 4
475
475
  summary: Process monitoring tool. Inspired from Bluepill and God. Requires Ruby(MRI)