runit-man 2.4.0a1 → 2.4.0a2
Sign up to get free protection for your applications and to get access to all the features.
- data/cookbooks/provisioning/recipes/default.rb +3 -0
- data/lib/runit-man/app.rb +32 -17
- data/lib/runit-man/service_info.rb +1 -0
- data/lib/runit-man/service_info/base.rb +40 -14
- data/lib/runit-man/service_info/logger.rb +51 -22
- data/lib/runit-man/service_info/svlogd.rb +25 -16
- data/lib/runit-man/version.rb +1 -1
- data/views/_service_info.haml +1 -1
- metadata +124 -198
- data/lib/runit-man/log_location_cache/base.rb +0 -110
- data/lib/runit-man/log_location_cache/logger.rb +0 -56
- data/lib/runit-man/log_location_cache/svlogd.rb +0 -34
data/lib/runit-man/app.rb
CHANGED
@@ -153,30 +153,45 @@ class RunitMan::App < Sinatra::Base
|
|
153
153
|
Yajl::Encoder.encode(service_infos)
|
154
154
|
end
|
155
155
|
|
156
|
+
def log_of_service_n(filepath, count, no)
|
157
|
+
text = ''
|
158
|
+
if File.readable?(filepath)
|
159
|
+
File::Tail::Logfile.open(filepath, :backward => count, :return_if_eof => true) do |log|
|
160
|
+
log.tail do |line|
|
161
|
+
text += line
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
{
|
167
|
+
:location => filepath,
|
168
|
+
:text => text,
|
169
|
+
:id => no
|
170
|
+
}
|
171
|
+
end
|
172
|
+
|
156
173
|
def log_of_service(name, count, no)
|
157
174
|
count = count.to_i
|
158
|
-
count = MIN_TAIL
|
159
|
-
count = MAX_TAIL
|
175
|
+
count = MIN_TAIL if count < MIN_TAIL
|
176
|
+
count = MAX_TAIL if count > MAX_TAIL
|
160
177
|
srv = ServiceInfo.klass[name]
|
161
178
|
return nil if srv.nil? || !srv.logged?
|
162
179
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
180
|
+
logs = []
|
181
|
+
if no.nil?
|
182
|
+
srv.log_file_locations.each_with_index do |filepath, no|
|
183
|
+
logs << log_of_service_n(filepath, count, no)
|
167
184
|
end
|
185
|
+
else
|
186
|
+
filepath = srv.log_file_locations[no]
|
187
|
+
return nil if filepath.nil?
|
188
|
+
logs << log_of_service_n(filepath, count, no)
|
168
189
|
end
|
169
190
|
|
170
191
|
{
|
171
192
|
:name => name,
|
172
193
|
:count => count,
|
173
|
-
:logs =>
|
174
|
-
{
|
175
|
-
:location => srv.log_file_location,
|
176
|
-
:text => text,
|
177
|
-
:id => 0
|
178
|
-
}
|
179
|
-
]
|
194
|
+
:logs => logs
|
180
195
|
}
|
181
196
|
end
|
182
197
|
|
@@ -224,7 +239,7 @@ class RunitMan::App < Sinatra::Base
|
|
224
239
|
|
225
240
|
haml :log_downloads, :locals => {
|
226
241
|
:name => name,
|
227
|
-
:files => srv.
|
242
|
+
:files => srv.all_log_file_locations
|
228
243
|
}
|
229
244
|
end
|
230
245
|
|
@@ -232,10 +247,10 @@ class RunitMan::App < Sinatra::Base
|
|
232
247
|
srv = ServiceInfo.klass[name]
|
233
248
|
return not_found if srv.nil? || !srv.logged?
|
234
249
|
|
235
|
-
f = srv.
|
250
|
+
f = srv.all_log_file_locations.detect { |f| f[:name] == file_name }
|
236
251
|
return not_found unless f
|
237
252
|
|
238
|
-
send_file(
|
253
|
+
send_file(f[:path], :type => 'text/plain', :disposition => 'attachment', :filename => f[:label], :last_modified => f[:modified].httpdate)
|
239
254
|
end
|
240
255
|
|
241
256
|
get '/view' do
|
@@ -244,7 +259,7 @@ class RunitMan::App < Sinatra::Base
|
|
244
259
|
|
245
260
|
@title = t('runit.view_file.title', :file => data[:name], :host => host_name)
|
246
261
|
content_type CONTENT_TYPES[:html], :charset => 'utf-8'
|
247
|
-
haml :view_file, :locals => data
|
262
|
+
haml :view_file, :locals => data
|
248
263
|
end
|
249
264
|
|
250
265
|
get '/view.txt' do
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require 'runit-man/log_location_cache/base'
|
2
1
|
require 'runit-man/service_status'
|
3
2
|
require 'runit-man/utils'
|
4
3
|
|
4
|
+
# Represents information about service on any host.
|
5
5
|
class ServiceInfo::Base
|
6
6
|
|
7
7
|
attr_reader :name
|
@@ -99,18 +99,13 @@ class ServiceInfo::Base
|
|
99
99
|
@log_status.pid
|
100
100
|
end
|
101
101
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
File.expand_path(rel_path, log_run_folder)
|
107
|
-
end
|
108
|
-
|
109
|
-
def log_file_path(file_name)
|
110
|
-
nil
|
102
|
+
# Current log file locations
|
103
|
+
def log_file_locations
|
104
|
+
[]
|
111
105
|
end
|
112
106
|
|
113
|
-
|
107
|
+
# All log file locations
|
108
|
+
def all_log_file_locations
|
114
109
|
[]
|
115
110
|
end
|
116
111
|
|
@@ -200,10 +195,41 @@ protected
|
|
200
195
|
@files[file_name] = ServiceInfo::Base.real_data_from_file(file_name)
|
201
196
|
end
|
202
197
|
|
203
|
-
def
|
204
|
-
return
|
198
|
+
def sorted_file_locations(file_locations)
|
199
|
+
return file_locations if file_locations.length < 2
|
200
|
+
|
201
|
+
file_locations.sort { |a, b| a[:created] <=> b[:created] }
|
202
|
+
end
|
203
|
+
|
204
|
+
def logger_name
|
205
|
+
not_implemented
|
206
|
+
end
|
207
|
+
|
208
|
+
def log_command
|
209
|
+
return nil if log_pid.nil?
|
210
|
+
|
211
|
+
ps_output = `ps -o args -p #{log_pid} 2>&1`.split("\n")
|
212
|
+
return nil if ps_output.length < 2
|
213
|
+
|
214
|
+
cmd = ps_output[1].chomp
|
215
|
+
cmd != '' ? cmd : nil
|
216
|
+
end
|
217
|
+
|
218
|
+
def log_command_args
|
219
|
+
cmd = log_command
|
220
|
+
return nil if cmd.nil?
|
221
|
+
|
222
|
+
args = cmd.split(/\s+/).select { |arg| arg !~ /^\-/ }
|
223
|
+
return nil if args.shift !~ /#{Regexp.escape(logger_name)}/
|
224
|
+
|
225
|
+
args
|
226
|
+
end
|
227
|
+
|
228
|
+
def log_folder_base_name
|
229
|
+
args = log_command_args
|
230
|
+
return nil if args.nil?
|
205
231
|
|
206
|
-
|
232
|
+
args.first
|
207
233
|
end
|
208
234
|
|
209
235
|
class << self
|
@@ -1,23 +1,55 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Represents information about service on logger-enabled host.
|
3
2
|
class ServiceInfo::Logger < ServiceInfo::Base
|
4
3
|
|
5
|
-
def
|
6
|
-
|
7
|
-
|
4
|
+
def logger_string
|
5
|
+
RunitMan::App.runit_logger
|
6
|
+
end
|
7
|
+
|
8
|
+
def logger_name
|
9
|
+
(logger_string =~ /^([^\:]+)\:/) ? $1 : logger_string
|
10
|
+
end
|
11
|
+
|
12
|
+
def log_base_folder
|
13
|
+
(logger_string =~ /^[^\:]+\:([^\:]+)/) ? $1 : nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def log_folder
|
17
|
+
folder = log_folder_base_name
|
18
|
+
(log_base_folder.nil? || folder.nil?) ? folder : File.expand_path(File.join(log_base_folder, folder))
|
19
|
+
end
|
20
|
+
|
21
|
+
def log_folder_base_name
|
22
|
+
result = super
|
8
23
|
|
9
|
-
|
10
|
-
|
24
|
+
# we should remove : from the end of the line for logger installations.
|
25
|
+
result = $1 if result =~ /^(.+)\:$/
|
11
26
|
|
12
|
-
|
27
|
+
result
|
13
28
|
end
|
14
29
|
|
15
|
-
|
16
|
-
|
17
|
-
|
30
|
+
# Current log file locations
|
31
|
+
def log_file_locations
|
32
|
+
folder = log_folder
|
33
|
+
return [] if folder.nil? || ! File.directory?(log_folder)
|
18
34
|
|
19
|
-
|
20
|
-
return [] unless File.directory?(
|
35
|
+
curdir = File.join(log_folder, Time.now.strftime('%Y-%m-%d'))
|
36
|
+
return [] unless File.directory?(curdir)
|
37
|
+
r = []
|
38
|
+
Dir.foreach(curdir) do |filename|
|
39
|
+
next if ServiceInfo::Base.itself_or_parent?(filename)
|
40
|
+
filepath = File.expand_path(filename, curdir)
|
41
|
+
next unless File.file?(filepath) && File.readable?(filepath)
|
42
|
+
|
43
|
+
r << filepath
|
44
|
+
end
|
45
|
+
|
46
|
+
r
|
47
|
+
end
|
48
|
+
|
49
|
+
# All log file locations
|
50
|
+
def all_log_file_locations
|
51
|
+
dir_name = log_folder
|
52
|
+
return [] if log_folder.nil? || ! File.directory?(dir_name)
|
21
53
|
|
22
54
|
r = []
|
23
55
|
Dir.foreach(dir_name) do |subdirname|
|
@@ -28,15 +60,17 @@ class ServiceInfo::Logger < ServiceInfo::Base
|
|
28
60
|
Dir.foreach(subdirpath) do |filename|
|
29
61
|
next if ServiceInfo::Base.itself_or_parent?(filename)
|
30
62
|
filepath = File.expand_path(filename, subdirpath)
|
31
|
-
label = "#{Utils.host_name}-#{filename}"
|
32
63
|
next unless File.file?(filepath) && File.readable?(filepath)
|
33
64
|
|
34
|
-
|
65
|
+
label = "#{Utils.host_name}-#{subdirname}-#{filename}"
|
66
|
+
|
67
|
+
stats = File.stat(filepath)
|
35
68
|
stat_times = [stats.ctime.utc, stats.atime.utc, stats.mtime.utc]
|
36
69
|
min_time, max_time = stat_times.min, stat_times.max
|
37
70
|
|
38
71
|
r << {
|
39
|
-
:name =>
|
72
|
+
:name => filename,
|
73
|
+
:path => filepath,
|
40
74
|
:label => label,
|
41
75
|
:size => stats.size,
|
42
76
|
:created => min_time,
|
@@ -44,13 +78,8 @@ class ServiceInfo::Logger < ServiceInfo::Base
|
|
44
78
|
}
|
45
79
|
end
|
46
80
|
end
|
47
|
-
sorted_log_files(r)
|
48
|
-
end
|
49
81
|
|
50
|
-
|
51
|
-
def log_location_cache
|
52
|
-
@log_location_cache ||= LogLocationCache::Logger.new(RunitMan::App.runit_logger)
|
53
|
-
end
|
82
|
+
sorted_file_locations(r)
|
54
83
|
end
|
55
84
|
end
|
56
85
|
|
@@ -1,22 +1,36 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Represents information about service on svlogd-enabled host.
|
3
2
|
class ServiceInfo::Svlogd < ServiceInfo::Base
|
4
3
|
SPECIAL_LOG_FILES = %w(lock config state newstate).freeze
|
5
4
|
|
6
|
-
def
|
7
|
-
|
8
|
-
|
5
|
+
def logger_name
|
6
|
+
'svlogd'
|
7
|
+
end
|
8
|
+
|
9
|
+
def log_folder
|
10
|
+
log_folder_base_name
|
11
|
+
end
|
12
|
+
|
13
|
+
# Current log file locations
|
14
|
+
def log_file_locations
|
15
|
+
folder = log_folder
|
16
|
+
return [] if folder.nil?
|
17
|
+
|
18
|
+
[ File.join(folder, 'current') ]
|
9
19
|
end
|
10
20
|
|
11
|
-
|
21
|
+
# All log file locations
|
22
|
+
def all_log_file_locations
|
23
|
+
dir_name = log_folder
|
24
|
+
return [] if dir_name.nil? || ! File.directory?(dir_name)
|
12
25
|
r = []
|
13
|
-
dir_name = File.dirname(log_file_location)
|
14
26
|
Dir.foreach(dir_name) do |name|
|
15
27
|
next if ServiceInfo::Base.itself_or_parent?(name)
|
16
28
|
next if SPECIAL_LOG_FILES.include?(name)
|
17
29
|
|
18
|
-
|
19
|
-
|
30
|
+
path = File.expand_path(name, dir_name)
|
31
|
+
next unless File.readable?(path)
|
32
|
+
|
33
|
+
stats = File.stat(path)
|
20
34
|
stat_times = [stats.ctime.utc, stats.atime.utc, stats.mtime.utc]
|
21
35
|
min_time, max_time = stat_times.min, stat_times.max
|
22
36
|
|
@@ -24,19 +38,14 @@ class ServiceInfo::Svlogd < ServiceInfo::Base
|
|
24
38
|
label = label.gsub(/[\:\s\,]/, '-').gsub(/[\\\/]/, '.')
|
25
39
|
r << {
|
26
40
|
:name => name,
|
41
|
+
:path => path,
|
27
42
|
:label => label,
|
28
43
|
:size => stats.size,
|
29
44
|
:created => min_time,
|
30
45
|
:modified => max_time
|
31
46
|
}
|
32
47
|
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
class << self
|
37
|
-
def log_location_cache
|
38
|
-
@log_location_cache ||= LogLocationCache::Svlogd.new
|
39
|
-
end
|
48
|
+
sorted_file_locations(r)
|
40
49
|
end
|
41
50
|
end
|
42
51
|
|
data/lib/runit-man/version.rb
CHANGED
data/views/_service_info.haml
CHANGED
@@ -23,7 +23,7 @@
|
|
23
23
|
= service_action service_info.name, :switch_up, t('runit.services.table.actions.switch_up')
|
24
24
|
%td
|
25
25
|
- if service_info.logged?
|
26
|
-
= log_link(service_info.name, :hint => t('runit.services.table.values.log_hint', :name => service_info.name), :blank => true, :title => service_info.
|
26
|
+
= log_link(service_info.name, :hint => t('runit.services.table.values.log_hint', :name => service_info.name), :blank => true, :title => service_info.log_file_locations.join(', '))
|
27
27
|
= log_downloads_link(service_info.name)
|
28
28
|
- else
|
29
29
|
= t('runit.services.table.values.log_absent')
|
metadata
CHANGED
@@ -1,234 +1,171 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: runit-man
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.4.0a2
|
5
5
|
prerelease: 5
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 4
|
9
|
-
- 0
|
10
|
-
- a
|
11
|
-
- 1
|
12
|
-
version: 2.4.0a1
|
13
6
|
platform: ruby
|
14
|
-
authors:
|
7
|
+
authors:
|
15
8
|
- Akzhan Abdulin
|
16
9
|
autorequire:
|
17
10
|
bindir: bin
|
18
11
|
cert_chain: []
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
type: :runtime
|
25
|
-
prerelease: false
|
26
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2012-04-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: yajl-ruby
|
16
|
+
requirement: &2158419480 !ruby/object:Gem::Requirement
|
27
17
|
none: false
|
28
|
-
requirements:
|
18
|
+
requirements:
|
29
19
|
- - ~>
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
|
32
|
-
segments:
|
33
|
-
- 1
|
34
|
-
- 0
|
35
|
-
version: "1.0"
|
36
|
-
name: yajl-ruby
|
37
|
-
requirement: *id001
|
38
|
-
- !ruby/object:Gem::Dependency
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
39
22
|
type: :runtime
|
40
23
|
prerelease: false
|
41
|
-
version_requirements:
|
24
|
+
version_requirements: *2158419480
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: haml
|
27
|
+
requirement: &2158418760 !ruby/object:Gem::Requirement
|
42
28
|
none: false
|
43
|
-
requirements:
|
29
|
+
requirements:
|
44
30
|
- - ~>
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
|
47
|
-
segments:
|
48
|
-
- 3
|
49
|
-
- 0
|
50
|
-
version: "3.0"
|
51
|
-
name: haml
|
52
|
-
requirement: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
54
33
|
type: :runtime
|
55
34
|
prerelease: false
|
56
|
-
version_requirements:
|
35
|
+
version_requirements: *2158418760
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: sinatra
|
38
|
+
requirement: &2158418300 !ruby/object:Gem::Requirement
|
57
39
|
none: false
|
58
|
-
requirements:
|
40
|
+
requirements:
|
59
41
|
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
segments:
|
63
|
-
- 1
|
64
|
-
- 3
|
65
|
-
version: "1.3"
|
66
|
-
name: sinatra
|
67
|
-
requirement: *id003
|
68
|
-
- !ruby/object:Gem::Dependency
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.3'
|
69
44
|
type: :runtime
|
70
45
|
prerelease: false
|
71
|
-
version_requirements:
|
46
|
+
version_requirements: *2158418300
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sinatra-content-for2
|
49
|
+
requirement: &2158417420 !ruby/object:Gem::Requirement
|
72
50
|
none: false
|
73
|
-
requirements:
|
51
|
+
requirements:
|
74
52
|
- - ~>
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
hash: 31
|
77
|
-
segments:
|
78
|
-
- 0
|
79
|
-
- 2
|
80
|
-
- 4
|
53
|
+
- !ruby/object:Gem::Version
|
81
54
|
version: 0.2.4
|
82
|
-
name: sinatra-content-for2
|
83
|
-
requirement: *id004
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
55
|
type: :runtime
|
86
56
|
prerelease: false
|
87
|
-
version_requirements:
|
57
|
+
version_requirements: *2158417420
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: i18n
|
60
|
+
requirement: &2158416360 !ruby/object:Gem::Requirement
|
88
61
|
none: false
|
89
|
-
requirements:
|
62
|
+
requirements:
|
90
63
|
- - ~>
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
|
93
|
-
segments:
|
94
|
-
- 0
|
95
|
-
- 5
|
96
|
-
version: "0.5"
|
97
|
-
name: i18n
|
98
|
-
requirement: *id005
|
99
|
-
- !ruby/object:Gem::Dependency
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0.5'
|
100
66
|
type: :runtime
|
101
67
|
prerelease: false
|
102
|
-
version_requirements:
|
68
|
+
version_requirements: *2158416360
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: file-tail
|
71
|
+
requirement: &2158414440 !ruby/object:Gem::Requirement
|
103
72
|
none: false
|
104
|
-
requirements:
|
73
|
+
requirements:
|
105
74
|
- - ~>
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
hash: 25
|
108
|
-
segments:
|
109
|
-
- 1
|
110
|
-
- 0
|
111
|
-
- 7
|
75
|
+
- !ruby/object:Gem::Version
|
112
76
|
version: 1.0.7
|
113
|
-
|
114
|
-
requirement: *id006
|
115
|
-
- !ruby/object:Gem::Dependency
|
116
|
-
type: :development
|
77
|
+
type: :runtime
|
117
78
|
prerelease: false
|
118
|
-
version_requirements:
|
79
|
+
version_requirements: *2158414440
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: rake
|
82
|
+
requirement: &2158413020 !ruby/object:Gem::Requirement
|
119
83
|
none: false
|
120
|
-
requirements:
|
84
|
+
requirements:
|
121
85
|
- - ~>
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
- 8
|
127
|
-
version: "0.8"
|
128
|
-
- - "!="
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
hash: 59
|
131
|
-
segments:
|
132
|
-
- 0
|
133
|
-
- 9
|
134
|
-
- 0
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0.8'
|
88
|
+
- - ! '!='
|
89
|
+
- !ruby/object:Gem::Version
|
135
90
|
version: 0.9.0
|
136
|
-
name: rake
|
137
|
-
requirement: *id007
|
138
|
-
- !ruby/object:Gem::Dependency
|
139
91
|
type: :development
|
140
92
|
prerelease: false
|
141
|
-
version_requirements:
|
142
|
-
|
143
|
-
requirements:
|
144
|
-
- - ">="
|
145
|
-
- !ruby/object:Gem::Version
|
146
|
-
hash: 3
|
147
|
-
segments:
|
148
|
-
- 0
|
149
|
-
version: "0"
|
93
|
+
version_requirements: *2158413020
|
94
|
+
- !ruby/object:Gem::Dependency
|
150
95
|
name: rspec-core
|
151
|
-
requirement:
|
152
|
-
|
96
|
+
requirement: &2158412020 !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
153
102
|
type: :development
|
154
103
|
prerelease: false
|
155
|
-
version_requirements:
|
156
|
-
|
157
|
-
requirements:
|
158
|
-
- - ">="
|
159
|
-
- !ruby/object:Gem::Version
|
160
|
-
hash: 3
|
161
|
-
segments:
|
162
|
-
- 0
|
163
|
-
version: "0"
|
104
|
+
version_requirements: *2158412020
|
105
|
+
- !ruby/object:Gem::Dependency
|
164
106
|
name: rspec-expectations
|
165
|
-
requirement:
|
166
|
-
|
107
|
+
requirement: &2158410660 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ! '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
167
113
|
type: :development
|
168
114
|
prerelease: false
|
169
|
-
version_requirements:
|
170
|
-
|
171
|
-
requirements:
|
172
|
-
- - ">="
|
173
|
-
- !ruby/object:Gem::Version
|
174
|
-
hash: 3
|
175
|
-
segments:
|
176
|
-
- 0
|
177
|
-
version: "0"
|
115
|
+
version_requirements: *2158410660
|
116
|
+
- !ruby/object:Gem::Dependency
|
178
117
|
name: rr
|
179
|
-
requirement:
|
180
|
-
|
118
|
+
requirement: &2158410240 !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ! '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
181
124
|
type: :development
|
182
125
|
prerelease: false
|
183
|
-
version_requirements:
|
184
|
-
|
185
|
-
requirements:
|
186
|
-
- - ">="
|
187
|
-
- !ruby/object:Gem::Version
|
188
|
-
hash: 3
|
189
|
-
segments:
|
190
|
-
- 0
|
191
|
-
version: "0"
|
126
|
+
version_requirements: *2158410240
|
127
|
+
- !ruby/object:Gem::Dependency
|
192
128
|
name: rack-test
|
193
|
-
requirement:
|
194
|
-
|
129
|
+
requirement: &2158409720 !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ! '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
195
135
|
type: :development
|
196
136
|
prerelease: false
|
197
|
-
version_requirements:
|
137
|
+
version_requirements: *2158409720
|
138
|
+
- !ruby/object:Gem::Dependency
|
139
|
+
name: bundler
|
140
|
+
requirement: &2158408740 !ruby/object:Gem::Requirement
|
198
141
|
none: false
|
199
|
-
requirements:
|
142
|
+
requirements:
|
200
143
|
- - ~>
|
201
|
-
- !ruby/object:Gem::Version
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
- 0
|
206
|
-
version: "1.0"
|
207
|
-
- - ">"
|
208
|
-
- !ruby/object:Gem::Version
|
209
|
-
hash: 3
|
210
|
-
segments:
|
211
|
-
- 1
|
212
|
-
- 0
|
213
|
-
- 10
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '1.0'
|
146
|
+
- - ! '>'
|
147
|
+
- !ruby/object:Gem::Version
|
214
148
|
version: 1.0.10
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
149
|
+
type: :development
|
150
|
+
prerelease: false
|
151
|
+
version_requirements: *2158408740
|
152
|
+
description: ! 'Simple runit (http://smarden.org/runit/) web management tool with
|
153
|
+
i18n.
|
154
|
+
|
155
|
+
|
220
156
|
Server will run by runit-man script.
|
221
|
-
|
157
|
+
|
158
|
+
|
222
159
|
More information available at https://github.com/Undev/runit-man
|
223
160
|
|
161
|
+
'
|
224
162
|
email: akzhan.abdulin@gmail.com
|
225
|
-
executables:
|
163
|
+
executables:
|
226
164
|
- runit-man
|
227
165
|
extensions: []
|
228
|
-
|
229
|
-
extra_rdoc_files:
|
166
|
+
extra_rdoc_files:
|
230
167
|
- README.markdown
|
231
|
-
files:
|
168
|
+
files:
|
232
169
|
- .gitignore
|
233
170
|
- .gitmodules
|
234
171
|
- CHANGELOG.markdown
|
@@ -255,9 +192,6 @@ files:
|
|
255
192
|
- lib/runit-man/app.rb
|
256
193
|
- lib/runit-man/config.ru
|
257
194
|
- lib/runit-man/helpers.rb
|
258
|
-
- lib/runit-man/log_location_cache/base.rb
|
259
|
-
- lib/runit-man/log_location_cache/logger.rb
|
260
|
-
- lib/runit-man/log_location_cache/svlogd.rb
|
261
195
|
- lib/runit-man/partials.rb
|
262
196
|
- lib/runit-man/rainbows.conf
|
263
197
|
- lib/runit-man/runner.rb
|
@@ -292,42 +226,34 @@ files:
|
|
292
226
|
- views/log.haml
|
293
227
|
- views/log_downloads.haml
|
294
228
|
- views/view_file.haml
|
295
|
-
has_rdoc: true
|
296
229
|
homepage: https://github.com/Undev/runit-man
|
297
230
|
licenses: []
|
298
|
-
|
299
231
|
post_install_message:
|
300
232
|
rdoc_options: []
|
301
|
-
|
302
|
-
require_paths:
|
233
|
+
require_paths:
|
303
234
|
- lib
|
304
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
235
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
305
236
|
none: false
|
306
|
-
requirements:
|
307
|
-
- -
|
308
|
-
- !ruby/object:Gem::Version
|
309
|
-
|
310
|
-
segments:
|
237
|
+
requirements:
|
238
|
+
- - ! '>='
|
239
|
+
- !ruby/object:Gem::Version
|
240
|
+
version: '0'
|
241
|
+
segments:
|
311
242
|
- 0
|
312
|
-
|
313
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
243
|
+
hash: -1381096489065286937
|
244
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
314
245
|
none: false
|
315
|
-
requirements:
|
316
|
-
- -
|
317
|
-
- !ruby/object:Gem::Version
|
318
|
-
hash: 25
|
319
|
-
segments:
|
320
|
-
- 1
|
321
|
-
- 3
|
322
|
-
- 1
|
246
|
+
requirements:
|
247
|
+
- - ! '>'
|
248
|
+
- !ruby/object:Gem::Version
|
323
249
|
version: 1.3.1
|
324
|
-
requirements:
|
250
|
+
requirements:
|
325
251
|
- none
|
326
252
|
rubyforge_project:
|
327
|
-
rubygems_version: 1.
|
253
|
+
rubygems_version: 1.8.15
|
328
254
|
signing_key:
|
329
255
|
specification_version: 3
|
330
256
|
summary: Runit web management tool.
|
331
|
-
test_files:
|
257
|
+
test_files:
|
332
258
|
- spec/functional/runit-man_spec.rb
|
333
259
|
- spec/spec_helper.rb
|
@@ -1,110 +0,0 @@
|
|
1
|
-
require 'monitor'
|
2
|
-
|
3
|
-
module LogLocationCache; end
|
4
|
-
|
5
|
-
class LogLocationCache::Base
|
6
|
-
TIME_LIMIT = 600
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
@monitor = Monitor.new
|
10
|
-
clear
|
11
|
-
end
|
12
|
-
|
13
|
-
def [](pid)
|
14
|
-
pid = pid.to_i
|
15
|
-
loc = nil
|
16
|
-
|
17
|
-
unless pids.include?(pid)
|
18
|
-
loc = get_pid_location(pid)
|
19
|
-
set_pid_log_location(pid, loc)
|
20
|
-
end
|
21
|
-
|
22
|
-
return loc unless loc.nil?
|
23
|
-
return nil unless pids.include?(pid)
|
24
|
-
|
25
|
-
pids[pid][:value]
|
26
|
-
end
|
27
|
-
|
28
|
-
protected
|
29
|
-
attr_accessor :query_counter
|
30
|
-
attr_accessor :pids
|
31
|
-
attr_reader :monitor
|
32
|
-
|
33
|
-
def not_implemented
|
34
|
-
raise NotImplementedError.new
|
35
|
-
end
|
36
|
-
|
37
|
-
def get_pid_location(lpid)
|
38
|
-
not_implemented
|
39
|
-
end
|
40
|
-
|
41
|
-
def clear
|
42
|
-
monitor.synchronize do
|
43
|
-
self.query_counter = 0
|
44
|
-
self.pids = {}
|
45
|
-
end
|
46
|
-
|
47
|
-
self
|
48
|
-
end
|
49
|
-
|
50
|
-
def remove_old_values
|
51
|
-
monitor.synchronize do
|
52
|
-
self.query_counter = query_counter + 1
|
53
|
-
if query_counter < 10
|
54
|
-
return
|
55
|
-
end
|
56
|
-
|
57
|
-
self.query_counter = 0
|
58
|
-
limit = Time.now - TIME_LIMIT
|
59
|
-
|
60
|
-
pids.keys.each do |pid|
|
61
|
-
if pids[pid][:time] < limit
|
62
|
-
pids.delete(pid)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
self
|
68
|
-
end
|
69
|
-
|
70
|
-
def log_command(lpid)
|
71
|
-
return nil if lpid.nil?
|
72
|
-
|
73
|
-
ps_output = `ps -o args -p #{lpid} 2>&1`.split("\n")
|
74
|
-
return nil if ps_output.length < 2
|
75
|
-
|
76
|
-
cmd = ps_output[1].chomp
|
77
|
-
cmd != '' ? cmd : nil
|
78
|
-
end
|
79
|
-
|
80
|
-
def logger_name
|
81
|
-
not_implemented
|
82
|
-
end
|
83
|
-
|
84
|
-
def log_command_args(lpid)
|
85
|
-
cmd = log_command(lpid)
|
86
|
-
return nil if cmd.nil?
|
87
|
-
|
88
|
-
args = cmd.split(/\s+/).select { |arg| arg !~ /^\-/ }
|
89
|
-
return nil if args.shift !~ /#{Regexp.escape(logger_name)}/
|
90
|
-
|
91
|
-
args
|
92
|
-
end
|
93
|
-
|
94
|
-
def log_folder_base_name(lpid)
|
95
|
-
args = log_command_args(lpid)
|
96
|
-
return nil if args.nil?
|
97
|
-
|
98
|
-
result = args.first
|
99
|
-
result
|
100
|
-
end
|
101
|
-
|
102
|
-
def log_folder(lpid)
|
103
|
-
not_implemented
|
104
|
-
end
|
105
|
-
|
106
|
-
def set_pid_log_location(pid, log_location)
|
107
|
-
not_implemented
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'monitor'
|
2
|
-
|
3
|
-
class LogLocationCache::Logger < LogLocationCache::Base
|
4
|
-
def initialize(logger)
|
5
|
-
super()
|
6
|
-
@logger = logger
|
7
|
-
end
|
8
|
-
|
9
|
-
protected
|
10
|
-
attr_reader :logger
|
11
|
-
|
12
|
-
def get_pid_location(lpid)
|
13
|
-
folder = log_folder(lpid)
|
14
|
-
return nil if folder.nil?
|
15
|
-
|
16
|
-
loc = File.join(folder, Time.now.strftime('%Y-%m-%d'), "#{log_folder_base_name(lpid)}.log")
|
17
|
-
unless File.exists?(loc)
|
18
|
-
loc = "#{loc}.gz"
|
19
|
-
loc = nil unless File.exists?(loc)
|
20
|
-
end
|
21
|
-
|
22
|
-
loc
|
23
|
-
end
|
24
|
-
|
25
|
-
def logger_name
|
26
|
-
(logger =~ /^([^\:]+)\:/) ? $1 : logger
|
27
|
-
end
|
28
|
-
|
29
|
-
def log_base_folder
|
30
|
-
(logger =~ /^[^\:]+\:([^\:]+)/) ? $1 : nil
|
31
|
-
end
|
32
|
-
|
33
|
-
def log_folder(lpid)
|
34
|
-
folder = log_folder_base_name(lpid)
|
35
|
-
(log_base_folder.nil? || folder.nil?) ? folder : File.join(log_base_folder, folder)
|
36
|
-
end
|
37
|
-
|
38
|
-
def log_priority(lpid)
|
39
|
-
args = log_command_args(lpid)
|
40
|
-
args.nil? ? logger_priority : args.last
|
41
|
-
end
|
42
|
-
|
43
|
-
def set_pid_log_location(pid, log_location)
|
44
|
-
remove_old_values
|
45
|
-
end
|
46
|
-
|
47
|
-
def log_folder_base_name(lpid)
|
48
|
-
result = super(lpid)
|
49
|
-
|
50
|
-
# we should remove : from the end of the line for logger installations.
|
51
|
-
result = $1 if result =~ /^(.+)\:$/
|
52
|
-
|
53
|
-
result
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'monitor'
|
2
|
-
|
3
|
-
class LogLocationCache::Svlogd < LogLocationCache::Base
|
4
|
-
|
5
|
-
protected
|
6
|
-
def get_pid_location(lpid)
|
7
|
-
folder = log_folder(lpid)
|
8
|
-
return nil if folder.nil?
|
9
|
-
|
10
|
-
File.join(folder, 'current')
|
11
|
-
end
|
12
|
-
|
13
|
-
def logger_name
|
14
|
-
'svlogd'
|
15
|
-
end
|
16
|
-
|
17
|
-
def log_folder(lpid)
|
18
|
-
log_folder_base_name(lpid)
|
19
|
-
end
|
20
|
-
|
21
|
-
def set_pid_log_location(pid, log_location)
|
22
|
-
remove_old_values
|
23
|
-
|
24
|
-
monitor.synchronize do
|
25
|
-
pids[pid.to_i] = {
|
26
|
-
:value => log_location,
|
27
|
-
:time => Time.now
|
28
|
-
}
|
29
|
-
end
|
30
|
-
|
31
|
-
self
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|