runit-man 2.2.9 → 2.3.1
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/app.rb +15 -3
- data/lib/runit-man/config.ru +24 -0
- data/lib/runit-man/helpers.rb +3 -2
- data/lib/runit-man/runner.rb +6 -2
- data/lib/runit-man/version.rb +1 -1
- data/views/_service_action.haml +3 -3
- data/views/_service_info.haml +3 -2
- data/views/_services.haml +1 -1
- data/views/view_file.haml +1 -1
- metadata +5 -4
data/lib/runit-man/app.rb
CHANGED
@@ -26,9 +26,10 @@ class RunitMan < Sinatra::Base
|
|
26
26
|
:js => 'application/x-javascript',
|
27
27
|
:json => 'application/json'
|
28
28
|
}.freeze
|
29
|
-
DEFAULT_LOGGER
|
29
|
+
DEFAULT_LOGGER = 'svlogd'.freeze
|
30
|
+
DEFAULT_ALL_SERVICES_DIR = '/etc/sv'.freeze
|
31
|
+
DEFAULT_ACTIVE_SERVICES_DIR = '/etc/service'.freeze
|
30
32
|
|
31
|
-
set :logger_option, DEFAULT_LOGGER
|
32
33
|
set :environment, :production
|
33
34
|
set :static, true
|
34
35
|
set :logging, true
|
@@ -228,6 +229,17 @@ class RunitMan < Sinatra::Base
|
|
228
229
|
end
|
229
230
|
|
230
231
|
class << self
|
232
|
+
def exec_rackup(command)
|
233
|
+
ENV['RUNIT_ALL_SERVICES_DIR'] = RunitMan.all_services_directory
|
234
|
+
ENV['RUNIT_ACTIVE_SERVICES_DIR'] = RunitMan.active_services_directory
|
235
|
+
ENV['RUNIT_LOGGER'] = RunitMan.logger
|
236
|
+
ENV['RUNIT_MAN_VIEW_FILES'] = RunitMan.files_to_view.join(',')
|
237
|
+
ENV['RUNIT_MAN_CREDENTIALS'] = RunitMan.allowed_users.keys.map { |user| "#{user}:#{RunitMan.allowed_users[user]}" }.join(',')
|
238
|
+
|
239
|
+
Dir.chdir(File.dirname(__FILE__))
|
240
|
+
exec(command)
|
241
|
+
end
|
242
|
+
|
231
243
|
def register_as_runit_service
|
232
244
|
all_r_dir = File.join(RunitMan.all_services_directory, 'runit-man')
|
233
245
|
active_r_dir = File.join(RunitMan.active_services_directory, 'runit-man')
|
@@ -263,7 +275,7 @@ class RunitMan < Sinatra::Base
|
|
263
275
|
end
|
264
276
|
|
265
277
|
def logger
|
266
|
-
settings.logger_option
|
278
|
+
settings.logger_option
|
267
279
|
end
|
268
280
|
|
269
281
|
def prepare_to_run
|
@@ -0,0 +1,24 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('..', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require 'runit-man/app'
|
4
|
+
|
5
|
+
RunitMan.set :active_services_directory, ENV['RUNIT_ACTIVE_SERVICES_DIR'] || RunitMan::DEFAULT_ACTIVE_SERVICES_DIR
|
6
|
+
RunitMan.set :all_services_directory, ENV['RUNIT_ALL_SERVICES_DIR'] || RunitMan::DEFAULT_ALL_SERVICES_DIR
|
7
|
+
RunitMan.set :logger_option, ENV['RUNIT_LOGGER'] || RunitMan::DEFAULT_LOGGER
|
8
|
+
|
9
|
+
if ENV['RUNIT_MAN_VIEW_FILES']
|
10
|
+
ENV['RUNIT_MAN_VIEW_FILES'].split(/\s*\,\s*/).each do |floc|
|
11
|
+
RunitMan.enable_view_of(floc)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
if ENV['RUNIT_MAN_CREDENTIALS']
|
16
|
+
ENV['RUNIT_MAN_CREDENTIALS'].split(/\s*\,\s*/).each do |cred|
|
17
|
+
RunitMan.add_user(*(cred.split(':', 2)))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
RunitMan.prepare_to_run
|
22
|
+
|
23
|
+
run RunitMan
|
24
|
+
|
data/lib/runit-man/helpers.rb
CHANGED
@@ -63,11 +63,11 @@ module Helpers
|
|
63
63
|
raw = options[:raw] || false
|
64
64
|
hint = " title=\"#{h(hint)}\"" unless hint.empty?
|
65
65
|
blank = blank ? ' target="_blank"' : ''
|
66
|
-
"<a#{hint}#{blank} href=\"/#{
|
66
|
+
"<a#{hint}#{blank} href=\"/#{name}/log#{ (count != 100) ? "/#{count}" : '' }#{ raw ? '.txt' : '' }#footer\">#{h(title)}</a>"
|
67
67
|
end
|
68
68
|
|
69
69
|
def log_downloads_link(name)
|
70
|
-
"<a target=\"_blank\" href=\"/#{
|
70
|
+
"<a target=\"_blank\" href=\"/#{name}/log-downloads\/\">#{h(t('runit.services.log.downloads'))}…</a>"
|
71
71
|
end
|
72
72
|
|
73
73
|
def even_or_odd
|
@@ -112,3 +112,4 @@ module Helpers
|
|
112
112
|
end.join(' ')
|
113
113
|
end
|
114
114
|
end
|
115
|
+
|
data/lib/runit-man/runner.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'optparse'
|
2
2
|
require 'runit-man/app'
|
3
3
|
|
4
|
-
RunitMan.set :active_services_directory,
|
5
|
-
RunitMan.set :all_services_directory,
|
4
|
+
RunitMan.set :active_services_directory, RunitMan::DEFAULT_ACTIVE_SERVICES_DIR
|
5
|
+
RunitMan.set :all_services_directory, RunitMan::DEFAULT_ALL_SERVICES_DIR
|
6
|
+
RunitMan.set :logger_option, RunitMan::DEFAULT_LOGGER
|
6
7
|
|
7
8
|
OptionParser.new { |op|
|
8
9
|
op.banner = 'Usage: runit-man <options>'
|
@@ -20,6 +21,9 @@ OptionParser.new { |op|
|
|
20
21
|
op.on('-v file_location', 'Enables view of specified file through runit-man') { |val| RunitMan.enable_view_of(val) }
|
21
22
|
op.on('-u user:password', 'Requires user name with given password to auth') { |val| RunitMan.add_user(*(val.split(':', 2))) }
|
22
23
|
op.separator 'Configuration options:'
|
24
|
+
op.on_tail('--rackup command_line', 'Change directory to config.ru location, set environment by options and execute specified command_line') do |command_line|
|
25
|
+
RunitMan.exec_rackup(command_line)
|
26
|
+
end
|
23
27
|
op.on_tail('-r', '--register', 'Register as runit service') do
|
24
28
|
RunitMan.register_as_runit_service
|
25
29
|
exit
|
data/lib/runit-man/version.rb
CHANGED
data/views/_service_action.haml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
- if enabled
|
2
|
-
%form.service-action{:action=>"#{
|
3
|
-
%input{:type=>"submit", :value=>
|
2
|
+
%form.service-action{:action=>"#{name}/#{action}", :method=>"POST"}
|
3
|
+
%input{:type=>"submit", :value=>label}/
|
4
4
|
- else
|
5
|
-
%input{:type=>"submit", :disabled=>"disabled", :value=>
|
5
|
+
%input{:type=>"submit", :disabled=>"disabled", :value=>label, :onclick=>"return false;"}/
|
data/views/_service_info.haml
CHANGED
@@ -31,9 +31,10 @@
|
|
31
31
|
= h(t('runit.services.table.values.files_to_view'))
|
32
32
|
%span :
|
33
33
|
- service_info.files_to_view.each do |f|
|
34
|
-
%a{:href=>"/view?file=#{
|
34
|
+
%a{:href=>"/view?file=#{f}"}= h(f)
|
35
35
|
- unless service_info.urls_to_view.empty?
|
36
36
|
= h(t('runit.services.table.values.urls_to_view'))
|
37
37
|
%span :
|
38
38
|
- service_info.urls_to_view.each do |url|
|
39
|
-
%a{:href=>
|
39
|
+
%a{:href=>url}= h(url)
|
40
|
+
|
data/views/_services.haml
CHANGED
data/views/view_file.haml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
- content_for :content do
|
2
2
|
= t('runit.view_file.header', :file =>h(name), :host => h(host_name))
|
3
3
|
|
|
4
|
-
%a{:href=>"/view.txt?file=#{
|
4
|
+
%a{:href=>"/view.txt?file=#{name}"}= t('runit.view_file.raw')
|
5
5
|
%pre= h(text)
|
6
6
|
- content_for :footer do
|
7
7
|
%p
|
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: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 2.
|
8
|
+
- 3
|
9
|
+
- 1
|
10
|
+
version: 2.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Akzhan Abdulin
|
@@ -201,6 +201,7 @@ extra_rdoc_files: []
|
|
201
201
|
files:
|
202
202
|
- bin/runit-man
|
203
203
|
- lib/runit-man/app.rb
|
204
|
+
- lib/runit-man/config.ru
|
204
205
|
- lib/runit-man/helpers.rb
|
205
206
|
- lib/runit-man/log_location_cache.rb
|
206
207
|
- lib/runit-man/partials.rb
|