runit-man 2.3.8 → 2.3.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,10 @@
1
1
  ## Changes
2
2
 
3
+ ### Version 2.3.8
4
+
5
+ * Minor update of handling logger log directories (we should remove last character from log directory name if it's equal to ':').
6
+ * Enabling of using 'bundle exec rake ...' command.
7
+
3
8
  ### Version 2.3.7
4
9
 
5
10
  * '--rackup' option now takes in care all specified options (earlier it takes in care only preceding options).
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- runit-man (2.3.8)
4
+ runit-man (2.3.9)
5
5
  file-tail (>= 1.0.5)
6
6
  haml (>= 3.0)
7
7
  i18n (>= 0.5.0)
@@ -12,21 +12,22 @@ PATH
12
12
  GEM
13
13
  remote: http://rubygems.org/
14
14
  specs:
15
- diff-lcs (1.1.2)
16
- file-tail (1.0.5)
17
- spruz (>= 0.1.0)
15
+ diff-lcs (1.1.3)
16
+ file-tail (1.0.6)
17
+ spruz (~> 0.2)
18
18
  haml (3.1.2)
19
19
  i18n (0.6.0)
20
- kgio (2.5.0)
21
- rack (1.3.0)
22
- rack-test (0.6.0)
20
+ kgio (2.6.0)
21
+ rack (1.3.2)
22
+ rack-test (0.6.1)
23
23
  rack (>= 1.0)
24
- rainbows (3.4.0)
25
- kgio (~> 2.4)
24
+ rainbows (4.3.1)
25
+ kgio (~> 2.5)
26
26
  rack (~> 1.1)
27
- unicorn (~> 3.6)
28
- rake (0.8.7)
29
- rr (1.0.2)
27
+ unicorn (~> 4.1)
28
+ raindrops (0.7.0)
29
+ rake (0.9.2)
30
+ rr (1.0.4)
30
31
  rspec-core (2.6.4)
31
32
  rspec-expectations (2.6.0)
32
33
  diff-lcs (~> 1.1.2)
@@ -36,12 +37,13 @@ GEM
36
37
  tilt (>= 1.2.2, < 2.0)
37
38
  sinatra-content-for2 (0.2.4)
38
39
  sinatra
39
- spruz (0.2.8)
40
- tilt (1.3.2)
41
- unicorn (3.7.0)
42
- kgio (~> 2.3)
40
+ spruz (0.2.13)
41
+ tilt (1.3.3)
42
+ unicorn (4.1.1)
43
+ kgio (~> 2.4)
43
44
  rack
44
- yajl-ruby (0.8.2)
45
+ raindrops (~> 0.6)
46
+ yajl-ruby (0.8.3)
45
47
 
46
48
  PLATFORMS
47
49
  ruby
@@ -4,6 +4,10 @@ Simple [runit](http://smarden.org/runit/ "runit home page") web management tool
4
4
 
5
5
  Server will run by **runit-man** script. Take a note that **runit-man** must have privileges like **runsvdir** process ones.
6
6
 
7
+ ## Screenshot
8
+
9
+ ![Screenshot](https://github.com/Undev/runit-man/raw/master/runit-man-screenshot.gif "Screenshot")
10
+
7
11
  ## Installation
8
12
 
9
13
  Usually You should install both **runit-man** and **thin** gems to run this tool fine.
@@ -4,6 +4,10 @@
4
4
 
5
5
  Сервер запускается скриптом **runit-man**. Примите во внимание, что **runit-man** обязан иметь привилегии, аналогичные привилегиям процесса **runsvdir**.
6
6
 
7
+ ## Скриншот
8
+
9
+ ![Скриншот](https://github.com/Undev/runit-man/raw/master/runit-man-screenshot.gif "Скриншот")
10
+
7
11
  ## Инсталляция
8
12
 
9
13
  Обычно вам нужно поставить гемы **runit-man** и **thin** совместно, чтобы эта утилита работала эффективно.
@@ -17,6 +17,7 @@ en:
17
17
  'yes': Does support low CPU usage using sendfile API.
18
18
  'no': Doesn''t support low CPU usage using sendfile API.
19
19
  services:
20
+ readonly: Only view enabled.
20
21
  table:
21
22
  caption: Services
22
23
  headers:
@@ -17,6 +17,7 @@ ru:
17
17
  'yes': Поддерживает низкое потребление CPU с использованием механизма sendfile.
18
18
  'no': Не поддерживает низкое потребление CPU с использованием механизма sendfile.
19
19
  services:
20
+ readonly: Только для просмотра.
20
21
  table:
21
22
  caption: Сервисы
22
23
  headers:
@@ -73,6 +73,11 @@ class RunitMan < Sinatra::Base
73
73
 
74
74
  helpers do
75
75
  include Helpers
76
+
77
+ def readonly?
78
+ @read_write_mode == :readonly
79
+ end
80
+
76
81
  end
77
82
 
78
83
  def self.i18n_location
@@ -98,6 +103,7 @@ class RunitMan < Sinatra::Base
98
103
  end
99
104
 
100
105
  before do
106
+ @read_write_mode = RunitMan.read_write_mode
101
107
  @scripts = []
102
108
  base_content_type = CONTENT_TYPES.keys.detect do |t|
103
109
  request.env['REQUEST_URI'] =~ /\.#{Regexp.escape(t.to_s)}$/
@@ -248,25 +254,36 @@ class RunitMan < Sinatra::Base
248
254
 
249
255
  def log_action(name, text)
250
256
  env = request.env
251
- addr = env.include?('X_REAL_IP') ? env['X_REAL_IP'] : env['REMOTE_ADDR']
252
- $stdout.puts "#{addr} - - [#{Time.now}] \"Do #{text} on #{name}\""
253
- $stdout.flush
257
+ log "#{addr} - - [#{Time.now}] \"Do #{text} on #{name}\""
258
+ end
259
+
260
+ def log_denied_action(name, text)
261
+ env = request.env
262
+ log "#{addr} - - [#{Time.now}] \"Receive #{text} for #{name}. Denied.\""
254
263
  end
255
264
 
256
265
  post '/:name/signal/:signal' do |name, signal|
257
- service = ServiceInfo[name]
258
- return not_found if service.nil?
259
- service.send_signal(signal)
260
- log_action(name, "send signal \"#{signal}\"")
266
+ unless readonly?
267
+ service = ServiceInfo[name]
268
+ return not_found if service.nil?
269
+ service.send_signal(signal)
270
+ log_action(name, "send signal \"#{signal}\"")
271
+ else
272
+ log_denied_action(name, "signal \"#{signal}\"")
273
+ end
261
274
  ''
262
275
  end
263
276
 
264
277
  post '/:name/:action' do |name, action|
265
- service = ServiceInfo[name]
266
- action = "#{action}!".to_sym
267
- return not_found if service.nil? || !service.respond_to?(action)
268
- service.send(action)
269
- log_action(name, action)
278
+ unless readonly?
279
+ service = ServiceInfo[name]
280
+ action = "#{action}!".to_sym
281
+ return not_found if service.nil? || !service.respond_to?(action)
282
+ service.send(action)
283
+ log_action(name, action)
284
+ else
285
+ log_denied_action(name, action)
286
+ end
270
287
  ''
271
288
  end
272
289
 
@@ -277,6 +294,7 @@ class RunitMan < Sinatra::Base
277
294
  ENV['RUNIT_LOGGER'] = RunitMan.runit_logger
278
295
  ENV['RUNIT_MAN_VIEW_FILES'] = RunitMan.files_to_view.join(',')
279
296
  ENV['RUNIT_MAN_CREDENTIALS'] = RunitMan.allowed_users.keys.map { |user| "#{user}:#{RunitMan.allowed_users[user]}" }.join(',')
297
+ ENV['RUNIT_MAN_READWRITE_MODE'] = RunitMan.read_write_mode.to_s
280
298
 
281
299
  Dir.chdir(File.dirname(__FILE__))
282
300
  exec(command)
@@ -338,6 +356,7 @@ class RunitMan < Sinatra::Base
338
356
  logger = RunitMan.runit_logger
339
357
  auth = RunitMan.allowed_users
340
358
  rackup_command_line = RunitMan.rackup_command_line
359
+ read_write_mode = RunitMan.read_write_mode.to_s
341
360
  File.open(script_name, 'w') do |script_source|
342
361
  script_source.print ERB.new(IO.read(template_name)).result(binding())
343
362
  end
@@ -4,7 +4,8 @@ require 'runit-man/app'
4
4
 
5
5
  RunitMan.set :active_services_directory, ENV['RUNIT_ACTIVE_SERVICES_DIR'] || RunitMan::DEFAULT_ACTIVE_SERVICES_DIR
6
6
  RunitMan.set :all_services_directory, ENV['RUNIT_ALL_SERVICES_DIR'] || RunitMan::DEFAULT_ALL_SERVICES_DIR
7
- RunitMan.set :runit_logger, ENV['RUNIT_LOGGER'] || RunitMan::DEFAULT_LOGGER
7
+ RunitMan.set :runit_logger, ENV['RUNIT_LOGGER'] || RunitMan::DEFAULT_LOGGER
8
+ RunitMan.set :read_write_mode, (ENV['RUNIT_READWRITE_MODE'] || 'rw').to_sym
8
9
 
9
10
  if ENV['RUNIT_MAN_VIEW_FILES']
10
11
  ENV['RUNIT_MAN_VIEW_FILES'].split(/\s*\,\s*/).each do |floc|
@@ -12,6 +12,15 @@ module Helpers
12
12
 
13
13
  attr_accessor :even_or_odd_state
14
14
 
15
+ def addr
16
+ env.include?('X_REAL_IP') ? env['X_REAL_IP'] : env['REMOTE_ADDR']
17
+ end
18
+
19
+ def log(s)
20
+ $stdout.puts s
21
+ $stdout.flush
22
+ end
23
+
15
24
  def host_name
16
25
  Utils.host_name
17
26
  end
@@ -5,6 +5,7 @@ RunitMan.set :active_services_directory, RunitMan::DEFAULT_ACTIVE_SERVICES_DIR
5
5
  RunitMan.set :all_services_directory, RunitMan::DEFAULT_ALL_SERVICES_DIR
6
6
  RunitMan.set :runit_logger, RunitMan::DEFAULT_LOGGER
7
7
  RunitMan.set :rackup_command_line, false
8
+ RunitMan.set :read_write_mode, :readwrite
8
9
 
9
10
  OptionParser.new { |op|
10
11
  op.banner = 'Usage: runit-man <options>'
@@ -13,6 +14,7 @@ OptionParser.new { |op|
13
14
  op.on('-s server') { |val| RunitMan.set :server, val }
14
15
  op.on('-p port') { |val| RunitMan.set :port, val.to_i }
15
16
  op.on('-b addr') { |val| RunitMan.set :bind, val } if RunitMan.respond_to?(:bind)
17
+ op.on('-m mode (rw by default)') { |val| RunitMan.set(:read_write_mode, :readonly) if val =~ /^read\-only|readonly|ro$/ }
16
18
  op.separator 'runit options:'
17
19
  op.on('-a active_services_directory (/etc/service by default)') { |val| RunitMan.set :active_services_directory, val }
18
20
  op.on('-f all_services_directory (/etc/sv by default)') { |val| RunitMan.set :all_services_directory, val }
@@ -1,5 +1,5 @@
1
1
  module RunitManVersion
2
- VERSION = '2.3.8'.freeze
2
+ VERSION = '2.3.9'.freeze
3
3
 
4
4
  class << self
5
5
  attr_accessor :sendfile
Binary file
data/sv/run.erb CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/bin/bash
2
2
  exec 2>&1
3
- exec runit-man<% if server.kind_of?(String) %> -s "<%= server %>"<% end %><% if bind %> -b <%= bind %><% end %> -p <%= port %> -a "<%= active_services_directory %>" -f "<%= all_services_directory %>"<% files_to_view.each do |f| %> -v "<%= f %>"<% end %><% auth.each_pair do |name, password| %> -u <%= name %>:<%= password %><% end %><%= logger ? " -l \"#{logger}\"" : '' %><% if rackup_command_line %> --rackup '<%= rackup_command_line %>'<% end %>
3
+ exec runit-man -m <%= read_write_mode.to_s %><% if server.kind_of?(String) %> -s "<%= server %>"<% end %><% if bind %> -b <%= bind %><% end %> -p <%= port %> -a "<%= active_services_directory %>" -f "<%= all_services_directory %>"<% files_to_view.each do |f| %> -v "<%= f %>"<% end %><% auth.each_pair do |name, password| %> -u <%= name %>:<%= password %><% end %><%= logger ? " -l \"#{logger}\"" : '' %><% if rackup_command_line %> --rackup '<%= rackup_command_line %>'<% end %>
4
4
 
@@ -6,18 +6,21 @@
6
6
  %td= service_info.uptime ? ('%.2f' % service_info.uptime) : ''
7
7
  %td= stat_subst(service_info.stat)
8
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')
9
+ - if readonly?
10
+ %strong= t('runit.services.readonly')
18
11
  - else
19
- - if service_info.switchable?
20
- = service_action service_info.name, :switch_up, t('runit.services.table.actions.switch_up')
12
+ - if service_info.active?
13
+ = service_action service_info.name, :restart, t('runit.services.table.actions.restart'), !service_info.down?
14
+ = service_action service_info.name, :down, t('runit.services.table.actions.stop'), !service_info.down?
15
+ = service_action service_info.name, :up, t('runit.services.table.actions.start'), service_info.down?
16
+ - unless service_info.down?
17
+ - service_info.allowed_signals.each do |signal|
18
+ = service_signal service_info.name, signal, t("runit.services.table.signals.#{signal}")
19
+ - if service_info.switchable?
20
+ = service_action service_info.name, :switch_down, t('runit.services.table.actions.switch_down')
21
+ - else
22
+ - if service_info.switchable?
23
+ = service_action service_info.name, :switch_up, t('runit.services.table.actions.switch_up')
21
24
  %td
22
25
  - if service_info.logged?
23
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_location)
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: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 3
9
- - 8
10
- version: 2.3.8
9
+ - 9
10
+ version: 2.3.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Akzhan Abdulin
@@ -15,10 +15,12 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-15 00:00:00 +04:00
18
+ date: 2011-09-05 00:00:00 +04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
+ name: yajl-ruby
23
+ prerelease: false
22
24
  version_requirements: &id001 !ruby/object:Gem::Requirement
23
25
  none: false
24
26
  requirements:
@@ -30,11 +32,11 @@ dependencies:
30
32
  - 7
31
33
  - 8
32
34
  version: 0.7.8
33
- name: yajl-ruby
34
35
  type: :runtime
35
- prerelease: false
36
36
  requirement: *id001
37
37
  - !ruby/object:Gem::Dependency
38
+ name: haml
39
+ prerelease: false
38
40
  version_requirements: &id002 !ruby/object:Gem::Requirement
39
41
  none: false
40
42
  requirements:
@@ -45,11 +47,11 @@ dependencies:
45
47
  - 3
46
48
  - 0
47
49
  version: "3.0"
48
- name: haml
49
50
  type: :runtime
50
- prerelease: false
51
51
  requirement: *id002
52
52
  - !ruby/object:Gem::Dependency
53
+ name: sinatra
54
+ prerelease: false
53
55
  version_requirements: &id003 !ruby/object:Gem::Requirement
54
56
  none: false
55
57
  requirements:
@@ -60,11 +62,11 @@ dependencies:
60
62
  - 1
61
63
  - 1
62
64
  version: "1.1"
63
- name: sinatra
64
65
  type: :runtime
65
- prerelease: false
66
66
  requirement: *id003
67
67
  - !ruby/object:Gem::Dependency
68
+ name: sinatra-content-for2
69
+ prerelease: false
68
70
  version_requirements: &id004 !ruby/object:Gem::Requirement
69
71
  none: false
70
72
  requirements:
@@ -76,11 +78,11 @@ dependencies:
76
78
  - 2
77
79
  - 4
78
80
  version: 0.2.4
79
- name: sinatra-content-for2
80
81
  type: :runtime
81
- prerelease: false
82
82
  requirement: *id004
83
83
  - !ruby/object:Gem::Dependency
84
+ name: i18n
85
+ prerelease: false
84
86
  version_requirements: &id005 !ruby/object:Gem::Requirement
85
87
  none: false
86
88
  requirements:
@@ -92,11 +94,11 @@ dependencies:
92
94
  - 5
93
95
  - 0
94
96
  version: 0.5.0
95
- name: i18n
96
97
  type: :runtime
97
- prerelease: false
98
98
  requirement: *id005
99
99
  - !ruby/object:Gem::Dependency
100
+ name: file-tail
101
+ prerelease: false
100
102
  version_requirements: &id006 !ruby/object:Gem::Requirement
101
103
  none: false
102
104
  requirements:
@@ -108,11 +110,11 @@ dependencies:
108
110
  - 0
109
111
  - 5
110
112
  version: 1.0.5
111
- name: file-tail
112
113
  type: :runtime
113
- prerelease: false
114
114
  requirement: *id006
115
115
  - !ruby/object:Gem::Dependency
116
+ name: rake
117
+ prerelease: false
116
118
  version_requirements: &id007 !ruby/object:Gem::Requirement
117
119
  none: false
118
120
  requirements:
@@ -124,11 +126,11 @@ dependencies:
124
126
  - 9
125
127
  - 0
126
128
  version: 0.9.0
127
- name: rake
128
129
  type: :development
129
- prerelease: false
130
130
  requirement: *id007
131
131
  - !ruby/object:Gem::Dependency
132
+ name: rspec-core
133
+ prerelease: false
132
134
  version_requirements: &id008 !ruby/object:Gem::Requirement
133
135
  none: false
134
136
  requirements:
@@ -138,11 +140,11 @@ dependencies:
138
140
  segments:
139
141
  - 0
140
142
  version: "0"
141
- name: rspec-core
142
143
  type: :development
143
- prerelease: false
144
144
  requirement: *id008
145
145
  - !ruby/object:Gem::Dependency
146
+ name: rspec-expectations
147
+ prerelease: false
146
148
  version_requirements: &id009 !ruby/object:Gem::Requirement
147
149
  none: false
148
150
  requirements:
@@ -152,11 +154,11 @@ dependencies:
152
154
  segments:
153
155
  - 0
154
156
  version: "0"
155
- name: rspec-expectations
156
157
  type: :development
157
- prerelease: false
158
158
  requirement: *id009
159
159
  - !ruby/object:Gem::Dependency
160
+ name: rr
161
+ prerelease: false
160
162
  version_requirements: &id010 !ruby/object:Gem::Requirement
161
163
  none: false
162
164
  requirements:
@@ -166,11 +168,11 @@ dependencies:
166
168
  segments:
167
169
  - 0
168
170
  version: "0"
169
- name: rr
170
171
  type: :development
171
- prerelease: false
172
172
  requirement: *id010
173
173
  - !ruby/object:Gem::Dependency
174
+ name: rack-test
175
+ prerelease: false
174
176
  version_requirements: &id011 !ruby/object:Gem::Requirement
175
177
  none: false
176
178
  requirements:
@@ -180,11 +182,11 @@ dependencies:
180
182
  segments:
181
183
  - 0
182
184
  version: "0"
183
- name: rack-test
184
185
  type: :development
185
- prerelease: false
186
186
  requirement: *id011
187
187
  - !ruby/object:Gem::Dependency
188
+ name: bundler
189
+ prerelease: false
188
190
  version_requirements: &id012 !ruby/object:Gem::Requirement
189
191
  none: false
190
192
  requirements:
@@ -196,9 +198,7 @@ dependencies:
196
198
  - 0
197
199
  - 10
198
200
  version: 1.0.10
199
- name: bundler
200
201
  type: :development
201
- prerelease: false
202
202
  requirement: *id012
203
203
  description: |
204
204
  Simple runit (http://smarden.org/runit/) web management tool with i18n.
@@ -248,6 +248,7 @@ files:
248
248
  - public/favicon.ico
249
249
  - public/js/jquery-1.6.1.min.js
250
250
  - public/js/runit-man.js
251
+ - runit-man-screenshot.gif
251
252
  - runit-man.gemspec
252
253
  - script/console
253
254
  - spec/functional/runit-man_spec.rb