runit-man 1.4.6 → 1.4.7
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/i18n/en.yml +1 -0
- data/i18n/ru.yml +1 -0
- data/lib/runit-man/app.rb +21 -11
- data/lib/runit-man/helpers.rb +2 -1
- data/views/log.erb +2 -1
- metadata +3 -3
data/i18n/en.yml
CHANGED
data/i18n/ru.yml
CHANGED
data/lib/runit-man/app.rb
CHANGED
@@ -10,6 +10,7 @@ MAX_TAIL = 10000
|
|
10
10
|
GEM_FOLDER = File.expand_path(File.join('..', '..'), File.dirname(__FILE__)).freeze
|
11
11
|
CONTENT_TYPES = {
|
12
12
|
:html => 'text/html',
|
13
|
+
:txt => 'text/plain',
|
13
14
|
:css => 'text/css',
|
14
15
|
:js => 'application/x-javascript',
|
15
16
|
:json => 'application/json'
|
@@ -32,12 +33,9 @@ class RunitMan < Sinatra::Base
|
|
32
33
|
end
|
33
34
|
|
34
35
|
before do
|
35
|
-
base_content_type =
|
36
|
-
|
37
|
-
|
38
|
-
when /\.json$/ then :json
|
39
|
-
else :html
|
40
|
-
end
|
36
|
+
base_content_type = CONTENT_TYPES.keys.detect do |t|
|
37
|
+
request.env['REQUEST_URI'] =~ /\.#{Regexp.escape(t.to_s)}$/
|
38
|
+
end || :html
|
41
39
|
content_type CONTENT_TYPES[base_content_type], :charset => 'utf-8'
|
42
40
|
end
|
43
41
|
|
@@ -55,15 +53,13 @@ class RunitMan < Sinatra::Base
|
|
55
53
|
service_infos.to_json
|
56
54
|
end
|
57
55
|
|
58
|
-
|
56
|
+
def log_of_service(name, count)
|
59
57
|
count = count.to_i
|
60
58
|
count = MIN_TAIL if count < MIN_TAIL
|
61
59
|
count = MAX_TAIL if count > MAX_TAIL
|
62
60
|
srv = ServiceInfo[name]
|
63
|
-
return
|
64
|
-
|
65
|
-
@title = t.runit.services.log.title(h(name), h(host_name), h(count), h(srv.log_file_location))
|
66
|
-
erb :log, :locals => {
|
61
|
+
return nil if srv.nil? || !srv.logged?
|
62
|
+
{
|
67
63
|
:name => name,
|
68
64
|
:count => count,
|
69
65
|
:log_location => srv.log_file_location,
|
@@ -71,6 +67,20 @@ class RunitMan < Sinatra::Base
|
|
71
67
|
}
|
72
68
|
end
|
73
69
|
|
70
|
+
get %r[^/([^/]+)/log(?:/(\d+))?/?$] do |name, count|
|
71
|
+
data = log_of_service(name, count)
|
72
|
+
return not_found if data.nil?
|
73
|
+
@scripts = []
|
74
|
+
@title = t.runit.services.log.title(h(name), h(host_name), h(count), h(data[:log_location]))
|
75
|
+
erb :log, :locals => data
|
76
|
+
end
|
77
|
+
|
78
|
+
get %r[^/([^/]+)/log(?:/(\d+))?\.txt$] do |name, count|
|
79
|
+
data = log_of_service(name, count)
|
80
|
+
return not_found if data.nil?
|
81
|
+
data[:text]
|
82
|
+
end
|
83
|
+
|
74
84
|
def log_action(name, text)
|
75
85
|
env = request.env
|
76
86
|
addr = env.include?('X_REAL_IP') ? env['X_REAL_IP'] : env['REMOTE_ADDR']
|
data/lib/runit-man/helpers.rb
CHANGED
@@ -39,9 +39,10 @@ module Helpers
|
|
39
39
|
title = options[:title].to_s || count
|
40
40
|
blank = options[:blank] || false
|
41
41
|
hint = options[:hint].to_s || ''
|
42
|
+
raw = options[:raw] || false
|
42
43
|
hint = " title=\"#{h(hint)}\"" unless hint.empty?
|
43
44
|
blank = blank ? ' target="_blank"' : ''
|
44
|
-
"<a#{hint}#{blank} href=\"/#{h(name)}/log#{ (count != 100) ? "/#{count}" : '' }#footer\">#{h(title)}</a>"
|
45
|
+
"<a#{hint}#{blank} href=\"/#{h(name)}/log#{ (count != 100) ? "/#{count}" : '' }#{ raw ? '.txt' : '' }#footer\">#{h(title)}</a>"
|
45
46
|
end
|
46
47
|
|
47
48
|
def even_or_odd
|
data/views/log.erb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
<% content_for :content do %>
|
2
|
-
<%= t.runit.services.log.header(h(name), h(host_name), h(count), h(log_location)) %>
|
2
|
+
<%= t.runit.services.log.header(h(name), h(host_name), h(count), h(log_location)) %> | <%= log_link(name, :count => count, :title => t.runit.services.log.raw, :raw => true) %>
|
3
|
+
|
3
4
|
<p>
|
4
5
|
<%= t.runit.services.log.counts([100, 250, 500, 1000, 5000].map { |n| log_link(name, :count => n, :title => n) }.join(' ')) %>
|
5
6
|
</p>
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 1.4.
|
8
|
+
- 7
|
9
|
+
version: 1.4.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Akzhan Abdulin
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-05 00:00:00 +04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|