runit-man 2.3.21 → 2.4.0a1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/runit-man/app.rb +47 -17
- data/lib/runit-man/helpers.rb +5 -0
- data/lib/runit-man/log_location_cache/base.rb +19 -7
- data/lib/runit-man/log_location_cache/logger.rb +7 -3
- data/lib/runit-man/log_location_cache/svlogd.rb +4 -1
- data/lib/runit-man/service_info/base.rb +22 -10
- data/lib/runit-man/service_info/logger.rb +30 -24
- data/lib/runit-man/service_info/svlogd.rb +1 -4
- data/lib/runit-man/service_status.rb +9 -7
- data/lib/runit-man/utils.rb +1 -0
- data/lib/runit-man/version.rb +1 -1
- metadata +14 -10
data/lib/runit-man/app.rb
CHANGED
@@ -53,17 +53,21 @@ class RunitMan::App < Sinatra::Base
|
|
53
53
|
|
54
54
|
def self.setup_i18n_files
|
55
55
|
files = []
|
56
|
+
|
56
57
|
Dir.glob("#{i18n_location}/*.yml") do |full_path|
|
57
|
-
next
|
58
|
+
next unless File.file?(full_path)
|
59
|
+
|
58
60
|
files << full_path
|
59
61
|
end
|
62
|
+
|
60
63
|
I18n.load_path = files
|
61
64
|
I18n.reload!
|
62
|
-
nil
|
65
|
+
nil
|
63
66
|
end
|
64
67
|
|
65
68
|
configure do
|
66
69
|
RunitMan::App.setup_i18n_files
|
70
|
+
|
67
71
|
haml_options = { :ugly => true }
|
68
72
|
haml_options[:encoding] = 'utf-8' if defined?(Encoding)
|
69
73
|
set :haml, haml_options
|
@@ -76,16 +80,20 @@ class RunitMan::App < Sinatra::Base
|
|
76
80
|
else
|
77
81
|
ServiceInfo.klass = ServiceInfo::Logger
|
78
82
|
end
|
83
|
+
|
79
84
|
@read_write_mode = RunitMan::App.read_write_mode
|
80
85
|
@scripts = []
|
86
|
+
|
81
87
|
base_content_type = CONTENT_TYPES.keys.detect do |t|
|
82
88
|
request.env['REQUEST_URI'] =~ /\.#{Regexp.escape(t.to_s)}$/
|
83
89
|
end || :html
|
84
90
|
content_type CONTENT_TYPES[base_content_type], :charset => 'utf-8'
|
91
|
+
|
85
92
|
headers({
|
86
93
|
'X-Powered-By' => 'runit-man',
|
87
94
|
'X-Version' => RunitMan::VERSION
|
88
95
|
})
|
96
|
+
|
89
97
|
parse_language(request.env['HTTP_ACCEPT_LANGUAGE'])
|
90
98
|
end
|
91
99
|
|
@@ -100,6 +108,7 @@ class RunitMan::App < Sinatra::Base
|
|
100
108
|
|
101
109
|
def parse_language(header)
|
102
110
|
weighted_locales = []
|
111
|
+
|
103
112
|
if header
|
104
113
|
header.split(',').each do |s|
|
105
114
|
if s =~ /^(.+)\;q\=(\d(?:\.\d)?)$/
|
@@ -109,12 +118,15 @@ class RunitMan::App < Sinatra::Base
|
|
109
118
|
end
|
110
119
|
end
|
111
120
|
end
|
121
|
+
|
112
122
|
weighted_locales << { :locale => :en, :weight => 0.0 }
|
123
|
+
|
113
124
|
if weighted_locales.length >= 2
|
114
125
|
weighted_locales.sort! do |a, b|
|
115
126
|
b[:weight] <=> a[:weight]
|
116
127
|
end
|
117
128
|
end
|
129
|
+
|
118
130
|
locales = weighted_locales.map { |wl| wl[:locale] }
|
119
131
|
setup_i18n(locales)
|
120
132
|
end
|
@@ -146,7 +158,8 @@ class RunitMan::App < Sinatra::Base
|
|
146
158
|
count = MIN_TAIL if count < MIN_TAIL
|
147
159
|
count = MAX_TAIL if count > MAX_TAIL
|
148
160
|
srv = ServiceInfo.klass[name]
|
149
|
-
return nil
|
161
|
+
return nil if srv.nil? || !srv.logged?
|
162
|
+
|
150
163
|
text = ''
|
151
164
|
File::Tail::Logfile.open(srv.log_file_location, :backward => count, :return_if_eof => true) do |log|
|
152
165
|
log.tail do |line|
|
@@ -171,8 +184,10 @@ class RunitMan::App < Sinatra::Base
|
|
171
184
|
if !request.GET.has_key?('file')
|
172
185
|
return nil
|
173
186
|
end
|
187
|
+
|
174
188
|
file_path = request.GET['file']
|
175
|
-
return nil
|
189
|
+
return nil unless all_files_to_view.include?(file_path)
|
190
|
+
|
176
191
|
text = IO.read(file_path)
|
177
192
|
{
|
178
193
|
:name => file_path,
|
@@ -182,7 +197,8 @@ class RunitMan::App < Sinatra::Base
|
|
182
197
|
|
183
198
|
get %r[^/([^/]+)/log(?:/(\d+))?/?$] do |name, count|
|
184
199
|
data = log_of_service(name, count, nil)
|
185
|
-
return not_found
|
200
|
+
return not_found if data.nil?
|
201
|
+
|
186
202
|
@title = t('runit.services.log.title', :name => name, :host => host_name, :count => count)
|
187
203
|
haml :log, :locals => data
|
188
204
|
end
|
@@ -193,15 +209,19 @@ class RunitMan::App < Sinatra::Base
|
|
193
209
|
else
|
194
210
|
count, no = nil, d1
|
195
211
|
end
|
212
|
+
|
196
213
|
no = no.to_i
|
214
|
+
|
197
215
|
data = log_of_service(name, count, no)
|
198
|
-
return not_found
|
216
|
+
return not_found if data.nil?
|
217
|
+
|
199
218
|
data[:logs][no][:text]
|
200
219
|
end
|
201
220
|
|
202
221
|
get %r[^/([^/]+)/log\-downloads/?$] do |name|
|
203
222
|
srv = ServiceInfo.klass[name]
|
204
|
-
return not_found
|
223
|
+
return not_found if srv.nil? || !srv.logged?
|
224
|
+
|
205
225
|
haml :log_downloads, :locals => {
|
206
226
|
:name => name,
|
207
227
|
:files => srv.log_files
|
@@ -210,17 +230,18 @@ class RunitMan::App < Sinatra::Base
|
|
210
230
|
|
211
231
|
get %r[^/([^/]+)/log\-download/(.+)$] do |name, file_name|
|
212
232
|
srv = ServiceInfo.klass[name]
|
213
|
-
return not_found
|
233
|
+
return not_found if srv.nil? || !srv.logged?
|
234
|
+
|
214
235
|
f = srv.log_files.detect { |f| f[:name] == file_name }
|
215
|
-
return not_found
|
236
|
+
return not_found unless f
|
237
|
+
|
216
238
|
send_file(srv.log_file_path(file_name), :type => 'text/plain', :disposition => 'attachment', :filename => f[:label], :last_modified => f[:modified].httpdate)
|
217
239
|
end
|
218
240
|
|
219
241
|
get '/view' do
|
220
242
|
data = data_of_file_view(request)
|
221
|
-
if data.nil?
|
222
|
-
|
223
|
-
end
|
243
|
+
return not_found if data.nil?
|
244
|
+
|
224
245
|
@title = t('runit.view_file.title', :file => data[:name], :host => host_name)
|
225
246
|
content_type CONTENT_TYPES[:html], :charset => 'utf-8'
|
226
247
|
haml :view_file, :locals => data
|
@@ -228,9 +249,8 @@ class RunitMan::App < Sinatra::Base
|
|
228
249
|
|
229
250
|
get '/view.txt' do
|
230
251
|
data = data_of_file_view(request)
|
231
|
-
if data.nil?
|
232
|
-
|
233
|
-
end
|
252
|
+
return not_found if data.nil?
|
253
|
+
|
234
254
|
content_type CONTENT_TYPES[:txt], :charset => 'utf-8'
|
235
255
|
data[:text]
|
236
256
|
end
|
@@ -248,7 +268,8 @@ class RunitMan::App < Sinatra::Base
|
|
248
268
|
post '/:name/signal/:signal' do |name, signal|
|
249
269
|
unless readonly?
|
250
270
|
service = ServiceInfo.klass[name]
|
251
|
-
return not_found
|
271
|
+
return not_found if service.nil?
|
272
|
+
|
252
273
|
service.send_signal(signal)
|
253
274
|
log_action(name, "send signal \"#{signal}\"")
|
254
275
|
else
|
@@ -261,7 +282,8 @@ class RunitMan::App < Sinatra::Base
|
|
261
282
|
unless readonly?
|
262
283
|
service = ServiceInfo.klass[name]
|
263
284
|
action = "#{action}!".to_sym
|
264
|
-
return not_found
|
285
|
+
return not_found if service.nil? || !service.respond_to?(action)
|
286
|
+
|
265
287
|
service.send(action)
|
266
288
|
log_action(name, action)
|
267
289
|
else
|
@@ -288,14 +310,18 @@ class RunitMan::App < Sinatra::Base
|
|
288
310
|
active_r_dir = File.join(RunitMan::App.active_services_directory, 'runit-man')
|
289
311
|
my_dir = File.join(GEM_FOLDER, 'sv')
|
290
312
|
log_dir = File.join(all_r_dir, 'log')
|
313
|
+
|
291
314
|
if File.symlink?(all_r_dir)
|
292
315
|
File.unlink(all_r_dir)
|
293
316
|
end
|
317
|
+
|
294
318
|
unless File.directory?(all_r_dir)
|
295
319
|
FileUtils.mkdir_p(log_dir)
|
296
320
|
create_log_run_script(all_r_dir)
|
297
321
|
end
|
322
|
+
|
298
323
|
create_run_script(all_r_dir)
|
324
|
+
|
299
325
|
unless File.symlink?(active_r_dir)
|
300
326
|
File.symlink(all_r_dir, active_r_dir)
|
301
327
|
end
|
@@ -340,9 +366,11 @@ class RunitMan::App < Sinatra::Base
|
|
340
366
|
auth = RunitMan::App.allowed_users
|
341
367
|
rackup_command_line = RunitMan::App.rackup_command_line
|
342
368
|
read_write_mode = RunitMan::App.read_write_mode.to_s
|
369
|
+
|
343
370
|
File.open(script_name, 'w') do |script_source|
|
344
371
|
script_source.print ERB.new(IO.read(template_name)).result(binding())
|
345
372
|
end
|
373
|
+
|
346
374
|
File.chmod(0755, script_name)
|
347
375
|
end
|
348
376
|
|
@@ -351,9 +379,11 @@ class RunitMan::App < Sinatra::Base
|
|
351
379
|
script_name = File.join(dir, 'log', 'run')
|
352
380
|
template_name = File.join(GEM_FOLDER, 'sv', 'log', 'run.erb')
|
353
381
|
logger = RunitMan::App.runit_logger
|
382
|
+
|
354
383
|
File.open(script_name, 'w') do |script_source|
|
355
384
|
script_source.print ERB.new(IO.read(template_name)).result(binding())
|
356
385
|
end
|
386
|
+
|
357
387
|
File.chmod(0755, script_name)
|
358
388
|
end
|
359
389
|
end
|
data/lib/runit-man/helpers.rb
CHANGED
@@ -72,6 +72,7 @@ module Helpers
|
|
72
72
|
id = options[:id] || false
|
73
73
|
hint = " title=\"#{h(hint)}\"" unless hint.empty?
|
74
74
|
blank = blank ? ' target="_blank"' : ''
|
75
|
+
|
75
76
|
"<a#{hint}#{blank} href=\"/#{name}/log#{ (count != 100) ? "/#{count}" : '' }#{ id ? "/#{id}" : '' }#{ raw ? '.txt' : '' }#footer\">#{h(title)}</a>"
|
76
77
|
end
|
77
78
|
|
@@ -92,6 +93,7 @@ module Helpers
|
|
92
93
|
sign = (bytes >= 0) ? '' : '-'
|
93
94
|
suffix = 'b'
|
94
95
|
bytes = bytes.abs.to_f
|
96
|
+
|
95
97
|
if bytes > GIGABYTE
|
96
98
|
bytes /= GIGABYTE
|
97
99
|
suffix = 'Gb'
|
@@ -102,7 +104,9 @@ module Helpers
|
|
102
104
|
bytes /= KILOBYTE
|
103
105
|
suffix = 'Kb'
|
104
106
|
end
|
107
|
+
|
105
108
|
bytes = ((bytes * 100 + 0.5).to_i.to_f / 100)
|
109
|
+
|
106
110
|
"#{sign}#{bytes}#{t("runit.services.log.#{suffix}")}"
|
107
111
|
end
|
108
112
|
|
@@ -110,6 +114,7 @@ module Helpers
|
|
110
114
|
s.split(/\s/).map do |s|
|
111
115
|
if s =~ /(\w+)/
|
112
116
|
word = $1
|
117
|
+
|
113
118
|
if t("runit.services.table.subst.#{word}") !~ /translation missing/
|
114
119
|
s.sub(word, t("runit.services.table.subst.#{word}"))
|
115
120
|
else
|
@@ -13,12 +13,15 @@ class LogLocationCache::Base
|
|
13
13
|
def [](pid)
|
14
14
|
pid = pid.to_i
|
15
15
|
loc = nil
|
16
|
+
|
16
17
|
unless pids.include?(pid)
|
17
18
|
loc = get_pid_location(pid)
|
18
19
|
set_pid_log_location(pid, loc)
|
19
20
|
end
|
20
|
-
|
21
|
-
return
|
21
|
+
|
22
|
+
return loc unless loc.nil?
|
23
|
+
return nil unless pids.include?(pid)
|
24
|
+
|
22
25
|
pids[pid][:value]
|
23
26
|
end
|
24
27
|
|
@@ -40,6 +43,7 @@ protected
|
|
40
43
|
self.query_counter = 0
|
41
44
|
self.pids = {}
|
42
45
|
end
|
46
|
+
|
43
47
|
self
|
44
48
|
end
|
45
49
|
|
@@ -49,21 +53,26 @@ protected
|
|
49
53
|
if query_counter < 10
|
50
54
|
return
|
51
55
|
end
|
56
|
+
|
52
57
|
self.query_counter = 0
|
53
58
|
limit = Time.now - TIME_LIMIT
|
59
|
+
|
54
60
|
pids.keys.each do |pid|
|
55
61
|
if pids[pid][:time] < limit
|
56
62
|
pids.delete(pid)
|
57
63
|
end
|
58
64
|
end
|
59
65
|
end
|
66
|
+
|
60
67
|
self
|
61
68
|
end
|
62
69
|
|
63
70
|
def log_command(lpid)
|
64
|
-
return nil
|
71
|
+
return nil if lpid.nil?
|
72
|
+
|
65
73
|
ps_output = `ps -o args -p #{lpid} 2>&1`.split("\n")
|
66
|
-
return nil
|
74
|
+
return nil if ps_output.length < 2
|
75
|
+
|
67
76
|
cmd = ps_output[1].chomp
|
68
77
|
cmd != '' ? cmd : nil
|
69
78
|
end
|
@@ -74,15 +83,18 @@ protected
|
|
74
83
|
|
75
84
|
def log_command_args(lpid)
|
76
85
|
cmd = log_command(lpid)
|
77
|
-
return nil
|
86
|
+
return nil if cmd.nil?
|
87
|
+
|
78
88
|
args = cmd.split(/\s+/).select { |arg| arg !~ /^\-/ }
|
79
|
-
return nil
|
89
|
+
return nil if args.shift !~ /#{Regexp.escape(logger_name)}/
|
90
|
+
|
80
91
|
args
|
81
92
|
end
|
82
93
|
|
83
94
|
def log_folder_base_name(lpid)
|
84
95
|
args = log_command_args(lpid)
|
85
|
-
return nil
|
96
|
+
return nil if args.nil?
|
97
|
+
|
86
98
|
result = args.first
|
87
99
|
result
|
88
100
|
end
|
@@ -11,12 +11,14 @@ protected
|
|
11
11
|
|
12
12
|
def get_pid_location(lpid)
|
13
13
|
folder = log_folder(lpid)
|
14
|
-
return
|
14
|
+
return nil if folder.nil?
|
15
|
+
|
15
16
|
loc = File.join(folder, Time.now.strftime('%Y-%m-%d'), "#{log_folder_base_name(lpid)}.log")
|
16
17
|
unless File.exists?(loc)
|
17
18
|
loc = "#{loc}.gz"
|
18
|
-
loc = nil
|
19
|
+
loc = nil unless File.exists?(loc)
|
19
20
|
end
|
21
|
+
|
20
22
|
loc
|
21
23
|
end
|
22
24
|
|
@@ -44,8 +46,10 @@ protected
|
|
44
46
|
|
45
47
|
def log_folder_base_name(lpid)
|
46
48
|
result = super(lpid)
|
49
|
+
|
47
50
|
# we should remove : from the end of the line for logger installations.
|
48
|
-
result = $1
|
51
|
+
result = $1 if result =~ /^(.+)\:$/
|
52
|
+
|
49
53
|
result
|
50
54
|
end
|
51
55
|
end
|
@@ -5,7 +5,8 @@ class LogLocationCache::Svlogd < LogLocationCache::Base
|
|
5
5
|
protected
|
6
6
|
def get_pid_location(lpid)
|
7
7
|
folder = log_folder(lpid)
|
8
|
-
return nil
|
8
|
+
return nil if folder.nil?
|
9
|
+
|
9
10
|
File.join(folder, 'current')
|
10
11
|
end
|
11
12
|
|
@@ -19,12 +20,14 @@ protected
|
|
19
20
|
|
20
21
|
def set_pid_log_location(pid, log_location)
|
21
22
|
remove_old_values
|
23
|
+
|
22
24
|
monitor.synchronize do
|
23
25
|
pids[pid.to_i] = {
|
24
26
|
:value => log_location,
|
25
27
|
:time => Time.now
|
26
28
|
}
|
27
29
|
end
|
30
|
+
|
28
31
|
self
|
29
32
|
end
|
30
33
|
end
|
@@ -101,7 +101,8 @@ class ServiceInfo::Base
|
|
101
101
|
|
102
102
|
def log_file_location
|
103
103
|
rel_path = ServiceInfo.klass.log_location_cache[log_pid]
|
104
|
-
return nil
|
104
|
+
return nil if rel_path.nil?
|
105
|
+
|
105
106
|
File.expand_path(rel_path, log_run_folder)
|
106
107
|
end
|
107
108
|
|
@@ -114,14 +115,16 @@ class ServiceInfo::Base
|
|
114
115
|
end
|
115
116
|
|
116
117
|
def send_signal(signal)
|
117
|
-
return
|
118
|
+
return unless supervise?
|
119
|
+
|
118
120
|
File.open(File.join(supervise_folder, 'control'), 'w') do |f|
|
119
121
|
f.print signal.to_s
|
120
122
|
end
|
121
123
|
end
|
122
124
|
|
123
125
|
def files_to_view
|
124
|
-
return []
|
126
|
+
return [] unless File.directory?(files_to_view_folder)
|
127
|
+
|
125
128
|
Dir.entries(files_to_view_folder).select do |name|
|
126
129
|
File.symlink?(File.join(files_to_view_folder, name))
|
127
130
|
end.map do |name|
|
@@ -135,7 +138,8 @@ class ServiceInfo::Base
|
|
135
138
|
end
|
136
139
|
|
137
140
|
def urls_to_view
|
138
|
-
return []
|
141
|
+
return [] unless File.directory?(urls_to_view_folder)
|
142
|
+
|
139
143
|
Dir.entries(urls_to_view_folder).select do |name|
|
140
144
|
name =~ /\.url$/ && File.file?(File.join(urls_to_view_folder, name))
|
141
145
|
end.map do |name|
|
@@ -146,7 +150,8 @@ class ServiceInfo::Base
|
|
146
150
|
end
|
147
151
|
|
148
152
|
def allowed_signals
|
149
|
-
return []
|
153
|
+
return [] unless File.directory?(allowed_signals_folder)
|
154
|
+
|
150
155
|
Dir.entries(allowed_signals_folder).reject do |name|
|
151
156
|
ServiceInfo::Base.itself_or_parent?(name)
|
152
157
|
end
|
@@ -190,12 +195,14 @@ protected
|
|
190
195
|
end
|
191
196
|
|
192
197
|
def data_from_file(file_name)
|
193
|
-
return @files[file_name]
|
198
|
+
return @files[file_name] if @files.include?(file_name)
|
199
|
+
|
194
200
|
@files[file_name] = ServiceInfo::Base.real_data_from_file(file_name)
|
195
201
|
end
|
196
202
|
|
197
203
|
def sorted_log_files(log_files)
|
198
204
|
return log_files if log_files.length < 2
|
205
|
+
|
199
206
|
log_files.sort { |a, b| a[:created] <=> b[:created] }
|
200
207
|
end
|
201
208
|
|
@@ -211,13 +218,15 @@ protected
|
|
211
218
|
end
|
212
219
|
|
213
220
|
def real_data_from_file(file_name)
|
214
|
-
return nil
|
221
|
+
return nil unless File.readable?(file_name)
|
222
|
+
|
215
223
|
if RUBY_VERSION >= '1.9'
|
216
224
|
data = IO.read(file_name, :external_encoding => 'ASCII-8BIT')
|
217
225
|
else
|
218
226
|
data = IO.read(file_name)
|
219
227
|
end
|
220
|
-
|
228
|
+
|
229
|
+
data.chomp! unless data.nil?
|
221
230
|
data.empty? ? nil : data
|
222
231
|
end
|
223
232
|
|
@@ -227,7 +236,8 @@ protected
|
|
227
236
|
|
228
237
|
private
|
229
238
|
def active_service_names
|
230
|
-
return []
|
239
|
+
return [] unless File.directory?(RunitMan::App.active_services_directory)
|
240
|
+
|
231
241
|
Dir.entries(RunitMan::App.active_services_directory).reject do |name|
|
232
242
|
full_name = File.join(RunitMan::App.active_services_directory, name)
|
233
243
|
itself_or_parent?(name) || (!File.symlink?(full_name) && !File.directory?(full_name))
|
@@ -235,8 +245,10 @@ protected
|
|
235
245
|
end
|
236
246
|
|
237
247
|
def inactive_service_names
|
238
|
-
return []
|
248
|
+
return [] unless File.directory?(RunitMan::App.all_services_directory)
|
249
|
+
|
239
250
|
actives = active_service_names
|
251
|
+
|
240
252
|
Dir.entries(RunitMan::App.all_services_directory).reject do |name|
|
241
253
|
full_name = File.join(RunitMan::App.all_services_directory, name)
|
242
254
|
itself_or_parent?(name) || !File.directory?(full_name) || actives.include?(name)
|
@@ -5,37 +5,44 @@ class ServiceInfo::Logger < ServiceInfo::Base
|
|
5
5
|
def log_file_path(file_name)
|
6
6
|
dir_name = File.dirname(File.dirname(log_file_location))
|
7
7
|
loc = File.expand_path(File.join(file_name, "#{name}.log"), dir_name)
|
8
|
-
|
9
|
-
loc =
|
8
|
+
|
9
|
+
loc = "#{loc}.gz" unless File.exists?(loc)
|
10
|
+
loc = nil unless File.exists?(loc)
|
11
|
+
|
10
12
|
loc
|
11
13
|
end
|
12
14
|
|
13
15
|
def log_files
|
14
16
|
lfloc = log_file_location
|
15
17
|
return [] if lfloc.nil?
|
18
|
+
|
19
|
+
dir_name = File.expand_path(File.dirname(File.dirname(lfloc)))
|
20
|
+
return [] unless File.directory?(dir_name)
|
21
|
+
|
16
22
|
r = []
|
17
|
-
dir_name
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
Dir.foreach(dir_name) do |subdirname|
|
24
|
+
next if ServiceInfo::Base.itself_or_parent?(subdirname)
|
25
|
+
subdirpath = File.expand_path(subdirname, dir_name)
|
26
|
+
next unless File.directory?(subdirpath)
|
27
|
+
|
28
|
+
Dir.foreach(subdirpath) do |filename|
|
29
|
+
next if ServiceInfo::Base.itself_or_parent?(filename)
|
30
|
+
filepath = File.expand_path(filename, subdirpath)
|
31
|
+
label = "#{Utils.host_name}-#{filename}"
|
32
|
+
next unless File.file?(filepath) && File.readable?(filepath)
|
33
|
+
|
34
|
+
stats = File.stat(file_name)
|
35
|
+
stat_times = [stats.ctime.utc, stats.atime.utc, stats.mtime.utc]
|
36
|
+
min_time, max_time = stat_times.min, stat_times.max
|
37
|
+
|
38
|
+
r << {
|
39
|
+
:name => name,
|
40
|
+
:label => label,
|
41
|
+
:size => stats.size,
|
42
|
+
:created => min_time,
|
43
|
+
:modified => max_time
|
44
|
+
}
|
27
45
|
end
|
28
|
-
stats = File.stat(file_name)
|
29
|
-
stat_times = [stats.ctime.utc, stats.atime.utc, stats.mtime.utc]
|
30
|
-
min_time, max_time = stat_times.min, stat_times.max
|
31
|
-
|
32
|
-
r << {
|
33
|
-
:name => name,
|
34
|
-
:label => label,
|
35
|
-
:size => stats.size,
|
36
|
-
:created => min_time,
|
37
|
-
:modified => max_time
|
38
|
-
}
|
39
46
|
end
|
40
47
|
sorted_log_files(r)
|
41
48
|
end
|
@@ -45,6 +52,5 @@ class ServiceInfo::Logger < ServiceInfo::Base
|
|
45
52
|
@log_location_cache ||= LogLocationCache::Logger.new(RunitMan::App.runit_logger)
|
46
53
|
end
|
47
54
|
end
|
48
|
-
|
49
55
|
end
|
50
56
|
|
@@ -14,6 +14,7 @@ class ServiceInfo::Svlogd < ServiceInfo::Base
|
|
14
14
|
Dir.foreach(dir_name) do |name|
|
15
15
|
next if ServiceInfo::Base.itself_or_parent?(name)
|
16
16
|
next if SPECIAL_LOG_FILES.include?(name)
|
17
|
+
|
17
18
|
full_name = File.expand_path(name, dir_name)
|
18
19
|
stats = File.stat(full_name)
|
19
20
|
stat_times = [stats.ctime.utc, stats.atime.utc, stats.mtime.utc]
|
@@ -33,13 +34,9 @@ class ServiceInfo::Svlogd < ServiceInfo::Base
|
|
33
34
|
end
|
34
35
|
|
35
36
|
class << self
|
36
|
-
|
37
37
|
def log_location_cache
|
38
38
|
@log_location_cache ||= LogLocationCache::Svlogd.new
|
39
39
|
end
|
40
|
-
|
41
40
|
end
|
42
|
-
|
43
|
-
|
44
41
|
end
|
45
42
|
|
@@ -9,6 +9,7 @@ class ServiceStatus
|
|
9
9
|
# status in daemontools supervise format
|
10
10
|
# look at runit's sv.c for details
|
11
11
|
data = (!data.nil? && data.length == STATUS_SIZE) ? data : nil
|
12
|
+
|
12
13
|
@raw = data.nil? ? nil : data.unpack('NNxxxxVxa1CC')
|
13
14
|
end
|
14
15
|
|
@@ -54,12 +55,13 @@ class ServiceStatus
|
|
54
55
|
end
|
55
56
|
|
56
57
|
def to_s
|
57
|
-
return 'inactive'
|
58
|
+
return 'inactive' if inactive?
|
59
|
+
|
58
60
|
# try to mimics stat behaviour to minimize readings
|
59
61
|
result = status_string
|
60
|
-
result += ', got TERM'
|
61
|
-
result += ', want down'
|
62
|
-
result += ', want up'
|
62
|
+
result += ', got TERM' if got_term?
|
63
|
+
result += ', want down' if want_down?
|
64
|
+
result += ', want up' if want_up?
|
63
65
|
result
|
64
66
|
end
|
65
67
|
|
@@ -70,9 +72,9 @@ private
|
|
70
72
|
|
71
73
|
def status_string
|
72
74
|
case status_byte
|
73
|
-
when S_DOWN
|
74
|
-
when S_RUN
|
75
|
-
when S_FINISH
|
75
|
+
when S_DOWN; 'down'
|
76
|
+
when S_RUN; 'run'
|
77
|
+
when S_FINISH; 'finish'
|
76
78
|
end
|
77
79
|
end
|
78
80
|
end
|
data/lib/runit-man/utils.rb
CHANGED
data/lib/runit-man/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runit-man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: -3194798914
|
5
|
+
prerelease: 5
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
-
|
10
|
-
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
- a
|
11
|
+
- 1
|
12
|
+
version: 2.4.0a1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- Akzhan Abdulin
|
@@ -15,7 +17,7 @@ autorequire:
|
|
15
17
|
bindir: bin
|
16
18
|
cert_chain: []
|
17
19
|
|
18
|
-
date: 2012-03
|
20
|
+
date: 2012-04-03 00:00:00 +04:00
|
19
21
|
default_executable:
|
20
22
|
dependencies:
|
21
23
|
- !ruby/object:Gem::Dependency
|
@@ -311,12 +313,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
311
313
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
312
314
|
none: false
|
313
315
|
requirements:
|
314
|
-
- - "
|
316
|
+
- - ">"
|
315
317
|
- !ruby/object:Gem::Version
|
316
|
-
hash:
|
318
|
+
hash: 25
|
317
319
|
segments:
|
318
|
-
-
|
319
|
-
|
320
|
+
- 1
|
321
|
+
- 3
|
322
|
+
- 1
|
323
|
+
version: 1.3.1
|
320
324
|
requirements:
|
321
325
|
- none
|
322
326
|
rubyforge_project:
|