runit-man 2.0.9 → 2.1.0

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'fileutils'
4
4
  require 'yajl'
5
- require 'erubis'
5
+ require 'haml'
6
6
  require 'i18n'
7
7
  require 'sinatra/base'
8
8
  require 'runit-man/helpers'
@@ -98,9 +98,9 @@ class RunitMan < Sinatra::Base
98
98
  end
99
99
 
100
100
  get '/' do
101
- @scripts = [ 'jquery-1.5.2.min' ]
101
+ @scripts = %w[ jquery-1.5.2.min runit-man ]
102
102
  @title = host_name
103
- erubis :index
103
+ haml :index
104
104
  end
105
105
 
106
106
  get '/services' do
@@ -129,13 +129,13 @@ class RunitMan < Sinatra::Base
129
129
  data = log_of_service(name, count)
130
130
  return not_found if data.nil?
131
131
  @title = t('runit.services.log.title', :name => h(name), :host => h(host_name), :count => h(count), :log_location => h(data[:log_location]))
132
- erubis :log, :locals => data
132
+ haml :log, :locals => data
133
133
  end
134
134
 
135
135
  get %r[^/([^/]+)/log\-downloads/?$] do |name|
136
136
  srv = ServiceInfo[name]
137
137
  return not_found if srv.nil? || !srv.logged?
138
- erubis :log_downloads, :locals => {
138
+ haml :log_downloads, :locals => {
139
139
  :name => name,
140
140
  :files => srv.log_files
141
141
  }
@@ -174,7 +174,7 @@ class RunitMan < Sinatra::Base
174
174
  end
175
175
  @title = t('runit.view_file.title', :file => h(data[:name]), :host => h(host_name))
176
176
  content_type CONTENT_TYPES[:html], :charset => 'utf-8'
177
- erubis :view_file, :locals => data
177
+ haml :view_file, :locals => data
178
178
  end
179
179
 
180
180
  get '/view.txt' do
@@ -189,7 +189,8 @@ class RunitMan < Sinatra::Base
189
189
  def log_action(name, text)
190
190
  env = request.env
191
191
  addr = env.include?('X_REAL_IP') ? env['X_REAL_IP'] : env['REMOTE_ADDR']
192
- puts "#{addr} - - [#{Time.now}] \"Do #{text} on #{name}\""
192
+ $stdout.puts "#{addr} - - [#{Time.now}] \"Do #{text} on #{name}\""
193
+ $stdout.flush
193
194
  end
194
195
 
195
196
  post '/:name/signal/:signal' do |name, signal|
@@ -16,7 +16,6 @@ module Helpers
16
16
  Utils.host_name
17
17
  end
18
18
 
19
-
20
19
  def t(*args)
21
20
  Utils.t(*args)
22
21
  end
@@ -8,11 +8,11 @@ module Sinatra::Partials
8
8
  options.merge!(:layout => false)
9
9
  if collection = options.delete(:collection) then
10
10
  collection.inject([]) do |buffer, member|
11
- buffer << erubis(:"#{template}", options.merge(:layout =>
11
+ buffer << haml(:"#{template}", options.merge(:layout =>
12
12
  false, :locals => {template_array[-1].to_sym => member}))
13
13
  end.join("\n")
14
14
  else
15
- erubis(:"#{template}", options)
15
+ haml(:"#{template}", options)
16
16
  end
17
17
  end
18
18
  end
@@ -1,4 +1,4 @@
1
1
  module RunitManVersion
2
- VERSION = '2.0.9'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
4
4
 
@@ -0,0 +1,5 @@
1
+ - if enabled
2
+ %form.service-action{:action=>"#{h(name)}/#{h(action)}", :method=>"POST"}
3
+ %input{:type=>"submit", :value=>h(label)}/
4
+ - else
5
+ %input{:type=>"submit", :disabled=>"disabled", :value=>h(label), :onclick=>"return false;"}/
@@ -0,0 +1,39 @@
1
+ - need_second_row = !service_info.files_to_view.empty? || !service_info.urls_to_view.empty?
2
+ %tr{:class=> even_or_odd ? 'even' : 'odd'}
3
+ %td{:rowspan=> need_second_row ? 2 : 1}= h(service_info.pid)
4
+ %th{:scope=>"row"}= h(service_info.name)
5
+ %td= service_info.started_at ? service_info.started_at.utc : ''
6
+ %td= service_info.uptime ? ('%.2f' % service_info.uptime) : ''
7
+ %td= stat_subst(service_info.stat)
8
+ %td
9
+ - if service_info.active?
10
+ = service_action service_info.name, :restart, t('runit.services.table.actions.restart'), !service_info.down?
11
+ = service_action service_info.name, :down, t('runit.services.table.actions.stop'), !service_info.down?
12
+ = service_action service_info.name, :up, t('runit.services.table.actions.start'), service_info.down?
13
+ - unless service_info.down?
14
+ - service_info.allowed_signals.each do |signal|
15
+ = service_signal service_info.name, signal, t("runit.services.table.signals.#{signal}")
16
+ - if service_info.switchable?
17
+ = service_action service_info.name, :switch_down, t('runit.services.table.actions.switch_down')
18
+ - else
19
+ - if service_info.switchable?
20
+ = service_action service_info.name, :switch_up, t('runit.services.table.actions.switch_up')
21
+ %td
22
+ - if service_info.logged?
23
+ = log_link(service_info.name, :hint => t('runit.services.table.values.log_hint', :name => service_info.name), :blank => true, :title => service_info.log_file_location)
24
+ = log_downloads_link(service_info.name)
25
+ - else
26
+ = t('runit.services.table.values.log_absent')
27
+ - if need_second_row
28
+ %tr
29
+ %td{:colspan=>6}
30
+ - unless service_info.files_to_view.empty?
31
+ = h(t('runit.services.table.values.files_to_view'))
32
+ %span :
33
+ - service_info.files_to_view.each do |f|
34
+ %a{:href=>"/view?file=#{h(f)}"}= h(f)
35
+ - unless service_info.urls_to_view.empty?
36
+ = h(t('runit.services.table.values.urls_to_view'))
37
+ %span :
38
+ - service_info.urls_to_view.each do |url|
39
+ %a{:href=>h(url)}= h(url)
@@ -0,0 +1,2 @@
1
+ %form.service-signal{:action=>"#{h(name)}/signal/#{h(signal)}", :method=>"POST"}
2
+ %input{:type=>"submit", :value=> h(label)}/
@@ -0,0 +1,21 @@
1
+ %table
2
+ %caption= h(t('runit.services.table.caption'))
3
+ %thead
4
+ %tr
5
+ %th= h(t('runit.services.table.headers.pid'))
6
+ %th= h(t('runit.services.table.headers.name'))
7
+ %th= h(t('runit.services.table.headers.started_at'))
8
+ %th= h(t('runit.services.table.headers.uptime'))
9
+ %th= h(t('runit.services.table.headers.stat'))
10
+ %th= h(t('runit.services.table.headers.actions'))
11
+ %th= h(t('runit.services.table.headers.log_file'))
12
+ %tfoot
13
+ %tr
14
+ %td{:colspan=>7}= t('runit.services.table.footer', :time => h(Time.now.utc))
15
+ %tbody
16
+ = partial(:service_info, :collection => service_infos)
17
+ %ul
18
+ - files_to_view.each do |f|
19
+ %li
20
+ %a{:target=>"_blank", :href=>"/view?file=#{h(f)}"}= h(f)
21
+
@@ -0,0 +1,7 @@
1
+ - content_for :content do
2
+ #error{:class=>"error"}
3
+ = h(t('runit.error', :err => '<span id="url"></span>'))
4
+ %span .
5
+ #services= t('runit.loading')
6
+ - content_for :footer do
7
+ %p= t('runit.footer', :sec => '<span id="service-refresh-interval">?</span>')
@@ -0,0 +1,23 @@
1
+ !!! 5
2
+ %html
3
+ %head
4
+ %title= h(t('runit.title', :p1 => @title, :p2 => t('runit.label')))
5
+ %link{:href=>"/css/tripoli.simple.css", :type=>"text/css", :rel=>"stylesheet"}/
6
+ %link{:href=>"/css/tripoli.visual.css", :type=>"text/css", :rel=>"stylesheet"}/
7
+ %link{:href=>"/css/tripoli.type.css", :type=>"text/css", :rel=>"stylesheet"}/
8
+ /[if IE]
9
+ %link{:href=>"/css/tripoli.simple.ie.css", :type=>"text/css", :rel=>"stylesheet"}/
10
+ %link{:href=>"/css/runit-man.css", :type=>"text/css", :rel=>"stylesheet"}/
11
+ %body
12
+ #container
13
+ #header
14
+ .content
15
+ %strong= h(t('runit.header', :p1 => host_name, :p2 => t('runit.label')))
16
+
17
+ .content= yield_content :content
18
+
19
+ #footer
20
+ .content= yield_content :footer
21
+ - @scripts.each do |name|
22
+ %script{:type=>"text/javascript", :src=>"/js/#{h(name)}.js"}
23
+
@@ -0,0 +1,12 @@
1
+ - content_for :content do
2
+ = t('runit.services.log.header', :name => h(name), :host => h(host_name), :count => h(count), :log_location => h(log_location))
3
+ &nbsp;|&nbsp;
4
+ = log_link(name, :count => count, :title => t('runit.services.log.raw'), :raw => true)
5
+ %p
6
+ = t('runit.services.log.counts', :count => [100, 250, 500, 1000, 5000].map { |n| log_link(name, :count => n, :title => n) }.join(' '))
7
+ = log_downloads_link(name)
8
+ %pre= h(text)
9
+ - content_for :footer do
10
+ %p
11
+ = t('runit.services.log.updated', :time => I18n.l(Time.now.utc))
12
+ %a{:href=>"javascript:;", :rel=>"nofollow", :onclick=>"window.location.reload()"}= t('runit.services.log.reload')
@@ -0,0 +1,23 @@
1
+ - content_for :content do
2
+ %h2= h(name)
3
+ %h3= h(t('runit.services.log.downloads'))
4
+ %table
5
+ %thead
6
+ %tr
7
+ %th= h(t('runit.services.log.modified'))
8
+ %th= h(t('runit.services.log.file_name'))
9
+ %th= h(t('runit.services.log.file_size'))
10
+ %th
11
+ %tfoot
12
+ %tr
13
+ %td{:colspan=>4}= h(t('runit.services.log.about_utc'))
14
+ %tbody
15
+ - files.each do |f|
16
+ %tr{:class=> even_or_odd ? 'even' : 'odd'}
17
+ %td= h(I18n.l(f[:modified]))
18
+ %td= h(f[:label])
19
+ %td{:title=>h(f[:size])}= h(human_bytes(f[:size]))
20
+ %td
21
+ %a{:href=>"/#{h(name)}/log-download/#{h(f[:name])}"}
22
+ = h(t('runit.services.log.download'))
23
+ &hellip;
@@ -0,0 +1,10 @@
1
+ - content_for :content do
2
+ = t('runit.view_file.header', :file =>h(name), :host => h(host_name))
3
+ &nbsp;|&nbsp;
4
+ %a{:href=>"/view.txt?file=#{h(name)}"}= t('runit.view_file.raw')
5
+ %pre= h(text)
6
+ - content_for :footer do
7
+ %p
8
+ = t('runit.view_file.updated', :time => Time.now.utc)
9
+ %a{:href=>"javascript:;", :rel=>"nofollow", :onclick=>"window.location.reload()"}= t('runit.view_file.reload')
10
+
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: 29
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
+ - 1
8
9
  - 0
9
- - 9
10
- version: 2.0.9
10
+ version: 2.1.0
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-04-21 00:00:00 +04:00
18
+ date: 2011-04-29 00:00:00 +04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -35,19 +35,18 @@ dependencies:
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: erubis
38
+ name: haml
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- hash: 1
45
+ hash: 7
46
46
  segments:
47
- - 2
48
47
  - 3
49
- - 1
50
- version: 2.3.1
48
+ - 0
49
+ version: "3.0"
51
50
  type: :runtime
52
51
  version_requirements: *id002
53
52
  - !ruby/object:Gem::Dependency
@@ -201,15 +200,15 @@ files:
201
200
  - public/css/tripoli.visual.css
202
201
  - public/js/jquery-1.5.2.min.js
203
202
  - public/js/runit-man.js
204
- - views/_service_action.erubis
205
- - views/_service_info.erubis
206
- - views/_service_signal.erubis
207
- - views/_services.erubis
208
- - views/index.erubis
209
- - views/layout.erubis
210
- - views/log.erubis
211
- - views/log_downloads.erubis
212
- - views/view_file.erubis
203
+ - views/_service_action.haml
204
+ - views/_service_info.haml
205
+ - views/_service_signal.haml
206
+ - views/_services.haml
207
+ - views/index.haml
208
+ - views/layout.haml
209
+ - views/log.haml
210
+ - views/log_downloads.haml
211
+ - views/view_file.haml
213
212
  - i18n/en.yml
214
213
  - i18n/ru.yml
215
214
  - sv/log/run.erb
@@ -1,7 +0,0 @@
1
- <% if enabled %>
2
- <form class="service-action" action="<%= h(name) %>/<%= h(action) %>" method="POST">
3
- <input type="submit" value="<%= h(label) %>" />
4
- </form>
5
- <% else %>
6
- <input type="submit" disabled="disabled" value="<%= h(label) %>" onclick="return false;" />
7
- <% end %>
@@ -1,52 +0,0 @@
1
- <%
2
- need_second_row = !service_info.files_to_view.empty? || !service_info.urls_to_view.empty?
3
- %>
4
- <tr class="<%= even_or_odd ? 'even' : 'odd' %>">
5
- <td<%= need_second_row ? ' rowspan="2"' : '' %>><%= h(service_info.pid) %></td>
6
- <th scope="row"><%= h(service_info.name) %></th>
7
- <td><%= service_info.started_at ? service_info.started_at.utc : '' %></td>
8
- <td><%= service_info.uptime ? ('%.2f' % service_info.uptime) : '' %></td>
9
- <td><%= stat_subst(service_info.stat) %></td>
10
- <td>
11
- <% if service_info.active? %>
12
- <%= service_action service_info.name, :restart, t('runit.services.table.actions.restart'), !service_info.down? %>
13
- <%= service_action service_info.name, :down, t('runit.services.table.actions.stop'), !service_info.down? %>
14
- <%= service_action service_info.name, :up, t('runit.services.table.actions.start'), service_info.down? %>
15
- <% unless service_info.down? %>
16
- <% service_info.allowed_signals.each do |signal| %>
17
- <%= service_signal service_info.name, signal, t("runit.services.table.signals.#{signal}") %>
18
- <% end %>
19
- <% end %>
20
- <% if service_info.switchable? %>
21
- <%= service_action service_info.name, :switch_down, t('runit.services.table.actions.switch_down') %>
22
- <% end %>
23
- <% else %>
24
- <% if service_info.switchable? %>
25
- <%= service_action service_info.name, :switch_up, t('runit.services.table.actions.switch_up') %>
26
- <% end %>
27
- <% end %>
28
- </td>
29
- <td>
30
- <% if service_info.logged? %>
31
- <%= log_link(service_info.name, :hint => t('runit.services.table.values.log_hint', :name => service_info.name), :blank => true, :title => service_info.log_file_location) %>
32
- <%= log_downloads_link(service_info.name) %>
33
- <% else %>
34
- <%= t('runit.services.table.values.log_absent') %>
35
- <% end %>
36
- </td>
37
- </tr>
38
- <% if need_second_row %><tr><td colspan="6">
39
- <% unless service_info.files_to_view.empty? %>
40
- <%= h(t('runit.services.table.values.files_to_view')) %>:
41
- <% service_info.files_to_view.each do |f| %>
42
- <a href="/view?file=<%= h(f) %>"><%= h(f) %></a>
43
- <% end %>
44
- <% end %>
45
- <% unless service_info.urls_to_view.empty? %>
46
- <%= h(t('runit.services.table.values.urls_to_view')) %>:
47
- <% service_info.urls_to_view.each do |url| %>
48
- <a href="<%= h(url) %>"><%= h(url) %></a>
49
- <% end %>
50
- <% end %>
51
-
52
- </td></tr><% end %>
@@ -1,3 +0,0 @@
1
- <form class="service-signal" action="<%= h(name) %>/signal/<%= h(signal) %>" method="POST">
2
- <input type="submit" value="<%= h(label) %>" />
3
- </form>
@@ -1,27 +0,0 @@
1
- <table>
2
- <caption><%= h(t('runit.services.table.caption')) %></caption>
3
- <thead>
4
- <tr>
5
- <th><%= h(t('runit.services.table.headers.pid')) %></th>
6
- <th><%= h(t('runit.services.table.headers.name')) %></th>
7
- <th><%= h(t('runit.services.table.headers.started_at')) %></th>
8
- <th><%= h(t('runit.services.table.headers.uptime')) %></th>
9
- <th><%= h(t('runit.services.table.headers.stat')) %></th>
10
- <th><%= h(t('runit.services.table.headers.actions')) %></th>
11
- <th><%= h(t('runit.services.table.headers.log_file')) %></th>
12
- </tr>
13
- </thead>
14
- <tfoot>
15
- <tr>
16
- <td colspan="7"><%= t('runit.services.table.footer', :time => h(Time.now.utc)) %></td>
17
- </tr>
18
- </tfoot>
19
- <tbody>
20
- <%= partial(:service_info, :collection => service_infos) %>
21
- </tbody>
22
- </table>
23
- <ul>
24
- <% files_to_view.each do |f| %>
25
- <li><a target="_blank" href="/view?file=<%= h(f) %>"><%= h(f) %></a></li>
26
- <% end %>
27
- </ul>
@@ -1,14 +0,0 @@
1
- <% content_for :content do %>
2
- <div id="error" class="error">
3
- <%= h(t('runit.error', :err => '<span id="url"></span>')) %>.
4
- </div>
5
- <div id="services">
6
- <%= t('runit.loading') %>
7
- </div>
8
- <% end %>
9
- <% content_for :footer do %>
10
- <p>
11
- <%= t('runit.footer', :sec => '<span id="service-refresh-interval">?</span>') %>
12
- </p>
13
- <% end %>
14
- <% @scripts << 'runit-man' %>
@@ -1,35 +0,0 @@
1
- <html>
2
- <head>
3
- <title><%= h(t('runit.title', :p1 => @title, :p2 => t('runit.label'))) %></title>
4
- <link href="/css/tripoli.simple.css" type="text/css" rel="stylesheet" />
5
- <link href="/css/tripoli.visual.css" type="text/css" rel="stylesheet" />
6
- <link href="/css/tripoli.type.css" type="text/css" rel="stylesheet" />
7
- <!--[if IE]><link href="/css/tripoli.simple.ie.css" type="text/css" rel="stylesheet" /><![endif]-->
8
- <link href="/css/runit-man.css" type="text/css" rel="stylesheet" />
9
- </head>
10
- <body>
11
- <div id="container">
12
- <div id="header">
13
- <div class="content">
14
- <strong><%= h(t('runit.header', :p1 => host_name, :p2 => t('runit.label'))) %></strong>
15
- </div>
16
- </div>
17
-
18
- <div class="content">
19
- <%= yield_content :content %>
20
- </div>
21
-
22
- <% if content_for?(:footer) %>
23
- <div id="footer">
24
- <div class="content">
25
- <%= yield_content :footer %>
26
- </div>
27
- </div>
28
- <% end %>
29
-
30
- </div>
31
- <% @scripts.each do |name| %>
32
- <script type="text/javascript" src="/js/<%= h(name) %>.js"></script>
33
- <% end %>
34
- </body>
35
- </html>
@@ -1,15 +0,0 @@
1
- <% content_for :content do %>
2
- <%= t('runit.services.log.header', :name => h(name), :host => h(host_name), :count => h(count), :log_location => h(log_location)) %> | <%= log_link(name, :count => count, :title => t('runit.services.log.raw'), :raw => true) %>
3
-
4
- <p>
5
- <%= t('runit.services.log.counts', :count => [100, 250, 500, 1000, 5000].map { |n| log_link(name, :count => n, :title => n) }.join(' ')) %>
6
- <%= log_downloads_link(name) %>
7
-
8
- </p>
9
- <pre><%= h(text) %></pre>
10
- <% end %>
11
- <% content_for :footer do %>
12
- <p>
13
- <%= t('runit.services.log.updated', :time => I18n.l(Time.now.utc)) %> <a href="javascript:;" rel="nofollow" onclick="window.location.reload()"><%= t('runit.services.log.reload') %></a>
14
- </p>
15
- <% end %>
@@ -1,28 +0,0 @@
1
- <% content_for :content do %>
2
- <h2><%= h(name) %></h2>
3
- <h3><%= h(t('runit.services.log.downloads')) %></h3>
4
- <table>
5
- <thead>
6
- <tr>
7
- <th><%= h(t('runit.services.log.modified')) %></th>
8
- <th><%= h(t('runit.services.log.file_name')) %></th>
9
- <th><%= h(t('runit.services.log.file_size')) %></th>
10
- <th></th>
11
- </tr>
12
- </thead>
13
- <tfoot>
14
- <tr>
15
- <td colspan="4"><%= h(t('runit.services.log.about_utc')) %></td>
16
- </tr>
17
- </tfoot>
18
- <tbody>
19
- <% files.each do |f| %>
20
- <tr class="<%= even_or_odd ? 'even' : 'odd' %>">
21
- <td><%= h(I18n.l(f[:modified])) %></td>
22
- <td><%= h(f[:label]) %></td>
23
- <td title="<%= h(f[:size]) %>"><%= h(human_bytes(f[:size])) %></td>
24
- <td><a href="/<%= h(name) %>/log-download/<%= h(f[:name]) %>"><%= h(t('runit.services.log.download')) %>&hellip;</a></td>
25
- </tr>
26
- <% end %>
27
- </tbody>
28
- <% end %>
@@ -1,10 +0,0 @@
1
- <% content_for :content do %>
2
- <%= t('runit.view_file.header', :file =>h(name), :host => h(host_name)) %> | <a href="/view.txt?file=<%= h(name) %>"><%= t('runit.view_file.raw') %></a>
3
-
4
- <pre><%= h(text) %></pre>
5
- <% end %>
6
- <% content_for :footer do %>
7
- <p>
8
- <%= t('runit.view_file.updated', :time => Time.now.utc) %> <a href="javascript:;" rel="nofollow" onclick="window.location.reload()"><%= t('runit.view_file.reload') %></a>
9
- </p>
10
- <% end %>