runit-man 2.3.1 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,11 @@
1
+ require 'monitor'
2
+
1
3
  class LogLocationCache
2
4
  TIME_LIMIT = 600
3
5
 
4
6
  def initialize(logger)
5
7
  @logger = logger
8
+ @monitor = Monitor.new
6
9
  clear
7
10
  end
8
11
 
@@ -22,23 +25,28 @@ private
22
25
  attr_accessor :query_counter
23
26
  attr_accessor :pids
24
27
  attr_reader :logger
28
+ attr_reader :monitor
25
29
 
26
30
  def clear
27
- self.query_counter = 0
28
- self.pids = {}
31
+ monitor.synchronize do
32
+ self.query_counter = 0
33
+ self.pids = {}
34
+ end
29
35
  self
30
36
  end
31
37
 
32
38
  def remove_old_values
33
- self.query_counter = query_counter + 1
34
- if query_counter < 10
35
- return
36
- end
37
- self.query_counter = 0
38
- limit = Time.now - TIME_LIMIT
39
- pids.keys.each do |pid|
40
- if pids[pid][:time] < limit
41
- pids.remove(pid)
39
+ monitor.synchronize do
40
+ self.query_counter = query_counter + 1
41
+ if query_counter < 10
42
+ return
43
+ end
44
+ self.query_counter = 0
45
+ limit = Time.now - TIME_LIMIT
46
+ pids.keys.each do |pid|
47
+ if pids[pid][:time] < limit
48
+ pids.remove(pid)
49
+ end
42
50
  end
43
51
  end
44
52
  self
@@ -96,11 +104,14 @@ private
96
104
  def set_pid_log_location(pid, log_location)
97
105
  remove_old_values
98
106
  if log_location =~ /current$/
99
- pids[pid.to_i] = {
100
- :value => log_location,
101
- :time => Time.now
102
- }
107
+ monitor.synchronize do
108
+ pids[pid.to_i] = {
109
+ :value => log_location,
110
+ :time => Time.now
111
+ }
112
+ end
103
113
  end
104
114
  self
105
115
  end
106
116
  end
117
+
@@ -0,0 +1,3 @@
1
+ Rainbows! do
2
+ use :ThreadSpawn
3
+ end
@@ -286,10 +286,7 @@ private
286
286
  end
287
287
 
288
288
  def log_location_cache
289
- unless @log_location_cache
290
- @log_location_cache = LogLocationCache.new(RunitMan.logger)
291
- end
292
- @log_location_cache
289
+ @log_location_cache ||= LogLocationCache.new(RunitMan.logger)
293
290
  end
294
291
 
295
292
  def real_data_from_file(file_name)
@@ -1,4 +1,4 @@
1
1
  module RunitManVersion
2
- VERSION = '2.3.1'.freeze
2
+ VERSION = '2.3.2'.freeze
3
3
  end
4
4
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runit-man
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 3
9
- - 1
10
- version: 2.3.1
9
+ - 2
10
+ version: 2.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Akzhan Abdulin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-27 00:00:00 +04:00
18
+ date: 2011-05-30 00:00:00 +04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -205,6 +205,7 @@ files:
205
205
  - lib/runit-man/helpers.rb
206
206
  - lib/runit-man/log_location_cache.rb
207
207
  - lib/runit-man/partials.rb
208
+ - lib/runit-man/rainbows.conf
208
209
  - lib/runit-man/runner.rb
209
210
  - lib/runit-man/service_info.rb
210
211
  - lib/runit-man/service_status.rb