runit-man 2.3.1 → 2.3.2
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.
- data/lib/runit-man/log_location_cache.rb +26 -15
- data/lib/runit-man/rainbows.conf +3 -0
- data/lib/runit-man/service_info.rb +1 -4
- data/lib/runit-man/version.rb +1 -1
- metadata +5 -4
@@ -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
|
-
|
28
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
pids
|
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
|
-
|
100
|
-
|
101
|
-
|
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
|
+
|
@@ -286,10 +286,7 @@ private
|
|
286
286
|
end
|
287
287
|
|
288
288
|
def log_location_cache
|
289
|
-
|
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)
|
data/lib/runit-man/version.rb
CHANGED
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:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 2.3.
|
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-
|
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
|