runit-man 2.3.6 → 2.3.7

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *.sw?
2
+ *.gem
3
+ Gemfile.lock
@@ -0,0 +1,230 @@
1
+ ## Changes
2
+
3
+ ### Version 2.3.7
4
+
5
+ * '--rackup' option now takes in care all specified options (earlier it takes in care only preceding options).
6
+ * Registration option now takes in care '--rackup' option.
7
+ * Minor refactoring.
8
+
9
+ ### Version 2.3.6
10
+ * Internationalization of system information page.
11
+ * favicon added.
12
+
13
+ ### Version 2.3.5
14
+ * Added /info (system information page).
15
+
16
+ ### Version 2.3.4
17
+ * Rack::File used to serve static files in old Sinatra releases (Sinatra 1.3.0 have this functionality built-in). Requires Rack 1.3.0 or higher.
18
+ * rainbows configuration now uses sendfile gem if it's available to decrease CPU usage on serving large files.
19
+
20
+ ### Version 2.3.3
21
+ * Typo (very old one).
22
+
23
+ ### Version 2.3.2
24
+ * Thread safety.
25
+ * rainbows.conf file provided aside config.ru to optimize running under rainbows application server.
26
+
27
+ ### Version 2.3.1
28
+ * New --rackup option to start runit-man using any Rack-compatible server (like unicorn/rainbows).
29
+
30
+ ### Version 2.2.9
31
+ * Fix runit-man service registration (bug introduced in 2.2.6).
32
+ * Upgrade jQuery to 1.6.1.
33
+
34
+ ### Version 2.2.8
35
+ * Encodings handling has been fixed (ruby 1.9 was affected) - prepor
36
+
37
+ ### Version 2.2.7
38
+ * Yet another fix for logger applied when no current log file exists.
39
+
40
+ ### Version 2.2.6
41
+ * Use standalone ERB instead of Erubis because we now not depend on erubis gem (registration broken in 2.1.1 when erubis is not installed).
42
+ * runit run scripts are fixed to use bash instead of any sh (thanks to hackru).
43
+
44
+ ### Version 2.2.5
45
+ * Try to show human readable error message when file cannot be parsed in UTF-8 encoding.
46
+
47
+ ### Version 2.2.4
48
+ * Fix haml options for ruby 1.8 (bug introduced in yanked 2.2.2)
49
+ * Try to show human readable error message when file cannot be parsed in UTF-8 encoding.
50
+
51
+ ### Version 2.2.3 (yanked)
52
+ * Upgrade jQuery to 1.6.
53
+ * Fix jslint errors and warnings.
54
+ * Spawning of tail command replaced with file-tail gem.
55
+ * Force UTF-8 encoding on file contents in ruby 1.9.
56
+
57
+ ### Version 2.1.2
58
+ * Sometimes we have no current log file in logger (no records in current day). Test for it.
59
+ * Updated logic of calculation of log file times.
60
+
61
+ ### Version 2.1.1
62
+ * erubis replaced with haml (because newest erubis breaks rendering of page).
63
+ * CSS updated.
64
+
65
+ ### Version 2.0.9
66
+ * English locale fixed (broken in 2.0.0).
67
+ * Caching fixed (broken in 2.0.7).
68
+
69
+ ### Version 2.0.7
70
+ * Caching of logger log locations removed, other caching was shortened.
71
+
72
+ ### Version 2.0.6
73
+ * Support for gzipped logs.
74
+
75
+ ### Version 2.0.2
76
+ * Fix log link hint, that's broken from 1.11.x (thanks to verm666).
77
+
78
+ ### Version 2.0.1
79
+ * Use Bundler to simplify development tasks.
80
+ * Fix registration of -l option.
81
+
82
+ ### Version 2.0.0
83
+ * Support for logger utility in addition to svlogd utility
84
+ * jQuery upgraded to version 1.5.2.
85
+
86
+ ### Version 1.11.6
87
+ * New column (started_at) has been added.
88
+
89
+ ### Version 1.11.4
90
+ * jQuery upgraded to version 1.5.1.
91
+ * Fixed i18n for en locale in log view (bug introduced in 1.11.0).
92
+ * Minor typo in ru locale.
93
+
94
+ ### Version 1.11.3
95
+ * Fixed i18n for file view (bug introduced in 1.11.0).
96
+
97
+ ### Version 1.11.0
98
+ * Switched from sinatra-r18n gem to i18n gem due to various aperiodic translation problems.
99
+
100
+ ### Version 1.10.3
101
+ * All time information in "Log downloads" section now represented in UTC.
102
+ * Downloaded file names for logs now include host name.
103
+ * Minor update of visual appearance of "Log downloads" section.
104
+
105
+ ### Version 1.10.2
106
+ * Log naming schema in "Log downloads" section has been changed to be more friendly.
107
+ * Special svlogd "state" and "newstate" files are skipped in Downloads section.
108
+ * Minor fix for ruby 1.9.2 in Rakefile (was broken in 1.10.1).
109
+
110
+ ### Version 1.10.1
111
+ * X-Powered-By and X-Version response headers added (to simplify management of installations).
112
+
113
+ ### Version 1.10.0
114
+ * Ability to download log files of concrete service.
115
+
116
+ ### Version 1.9.8
117
+ * jQuery upgraded to version 1.5.0.
118
+
119
+ ### Version 1.9.7
120
+ * Useless json gem compatibility layer has been removed.
121
+
122
+ ### Version 1.9.6
123
+ * Home has been moved to https://github.com/Undev/runit-man.
124
+
125
+ ### Version 1.9.5
126
+ * Support for Ruby 1.9.2.
127
+ * Use native Erubis support of Sinatra.
128
+ * Switch from sinatra-content-for gem to sinatra-content-for2 gem.
129
+
130
+ ### Version 1.9.4
131
+ * Use RSpec 2.
132
+
133
+ ### Version 1.9.3
134
+ * jQuery upgraded from version 1.4.2 to version 1.4.4.
135
+ * Switch from json gem to yajl-ruby gem.
136
+
137
+ ### Versions 1.9.0 up to 1.9.2
138
+ * BasicAuth supported by -u user:password option (multiple occurences allowed).
139
+
140
+ ### Version 1.8.4
141
+ * Now status of services read from status file instead of both status and stat.
142
+
143
+ ### Version 1.8.3
144
+ * Fix view of files that have extension like '.json', '.html' etc.
145
+
146
+ ### Versions 1.8.1 up to 1.8.2
147
+ * Minor visual improvements.
148
+
149
+ ### Version 1.8.0
150
+ * Allow to send custom signal through Web interface
151
+ if these specified in SV/runit-man/allowed-signals folder.
152
+
153
+ ### Versions 1.7.0 up to 1.7.4
154
+ * Uptime and pid now retrieved from daemontools-compatible status.
155
+ * Files are cached.
156
+ * Uptime is shown.
157
+
158
+ ### Version 1.6.4
159
+ * Fix for new versions of json gem.
160
+
161
+ ### Versions 1.6.0 up to 1.6.3
162
+ * Ability to view files and urls associated with service.
163
+ * Small fixes.
164
+
165
+ ### Version 1.5.4
166
+ * More correct way to register itself as runit service.
167
+
168
+ ### Version 1.5.3
169
+ * Fix link to view file as text/plain.
170
+
171
+ ### Version 1.5.2
172
+ * Fix reregistration as runit service.
173
+
174
+ ### Version 1.5.1
175
+ * Fix registration as runit service.
176
+
177
+ ### Version 1.5.0
178
+ * We can view files in predefined locations (see command line options).
179
+
180
+ ### Version 1.4.9
181
+ * More readable description for rubygems.
182
+
183
+ ### Version 1.4.8
184
+ * runit-man now supports sending of any signals through API.
185
+
186
+ ### Version 1.4.7
187
+ * runit-man now supports output of logs in raw text/plain format.
188
+
189
+ ### Version 1.4.6
190
+ * runit-man now can show custom count of lines per log.
191
+
192
+ ### Version 1.4.5
193
+ * Fix error when ran on machine when it's name cannot be resolved by DNS.
194
+ * /services.json added to provide automation API.
195
+
196
+ ### Version 1.4.3
197
+ * Add dependency to nearest r18n library that run on ruby 1.8.6
198
+ * Script renamed to runit-man without extension.
199
+
200
+ ### Version 1.4.1
201
+ * Workaround for rubygems behavior (sometimes it doesn't update binaries).
202
+
203
+ ### Version 1.4
204
+ * Automated registration with given options.
205
+
206
+ ### Version 1.3
207
+ * Automated registration as runit service (-r option).
208
+
209
+ ### Version 1.2
210
+ * First public release
211
+ * Some wrong installed services cannot be switched because installed
212
+ as directories instead of symlinks.
213
+
214
+ ### Version 1.1
215
+ * After sending of actions state was retrieved from server too often.
216
+ * Performed actions now logged.
217
+ * Services now can be activated and deactivated.
218
+ * Refactoring of LogLocationCache.
219
+ * Locations of runit folders now can be set through command line.
220
+
221
+ ### Version 1.0
222
+ * Packaged into gem.
223
+ * I18n (en and ru locales added).
224
+ * Visual improvements.
225
+
226
+ ### Version 0.2
227
+ * Visual improvements.
228
+
229
+ ### Version 0.1
230
+ * First working release
data/DESCRIPTION ADDED
@@ -0,0 +1,5 @@
1
+ Simple runit (http://smarden.org/runit/) web management tool with i18n.
2
+
3
+ Server will run by runit-man script.
4
+
5
+ More information available at https://github.com/Undev/runit-man
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ group :rainbows do
6
+ gem "rack", ">= 1.3.0"
7
+ gem "rainbows"
8
+ gem "sendfile", :platforms => "mri_18"
9
+ end
10
+
data/INSTALL ADDED
@@ -0,0 +1,33 @@
1
+ You need ruby 1.8.6 or above and rubygems installed.
2
+
3
+ Use following command to install runit-man:
4
+ gem install runit-man
5
+
6
+ Take a look at runit-man script options:
7
+
8
+ -p - Port to listen (4567 by default)
9
+ -b - IP Address to bind (0.0.0.0 by default)
10
+ -a - Directory of activated services (/etc/service by default)
11
+ -f - Directory of all known services (/etc/sv by default)
12
+ -u - User and password delimited by ':' for HTTP authentication (disabled by default)
13
+ -r - Register runit-man as runit service (as defined by other options)
14
+ --rackup='command' - Runs specified command in folder where is runit'man's config.ru located.
15
+
16
+ Usually you need thin gem to run runit-man effectively.
17
+ gem install thin
18
+
19
+ When You need to handle large files (logs etc.) by runit-man script You need another setup:
20
+ * Install rainbows gem (it prevents memory consumption).
21
+ * Upgrade rack gem to version 1.3 or higher and install sendfile gem if possible (It decreases CPU usage in combination with rainbows).
22
+ * Run runit-man as:
23
+
24
+ runit-man --rackup='rainbows -E production -c rainbows.conf -p <PORT>'
25
+
26
+ Any localization can be done by editing of ./i18n/*.yml locale files.
27
+ Contributions are welcome.
28
+
29
+ runit home page: http://smarden.org/runit/
30
+ runit-man home page: https://github.com/Undev/runit-man
31
+
32
+ Yours sincerely,
33
+ Akzhan.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2010 Akzhan Abdulin
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
data/README.markdown ADDED
@@ -0,0 +1,91 @@
1
+ ## Description
2
+
3
+ Simple [runit](http://smarden.org/runit/ "runit home page") web management tool with internationalization support.
4
+
5
+ Server will run by **runit-man** script. Take a note that **runit-man** must have privileges like **runsvdir** process ones.
6
+
7
+ ## Installation
8
+
9
+ Usually You should install both **runit-man** and **thin** gems to run this tool fine.
10
+ `gem install runit-man thin`
11
+
12
+ Pragmatic approach is to setup runit-man as runit service like this:
13
+ `runit-man -p 14500 -r`
14
+
15
+ This command installs runit-man as runit service (using default folders */etc/sv/* and */etc/service/*).
16
+
17
+ Look at INSTALL for details.
18
+
19
+ ### rackup configuration
20
+
21
+ Take a note that runit-man gem also provides config.ru rackup configuration file.
22
+ It's useful for running under unicorn/rainbows etc. `runit-man --rackup=command` option does `cd config.ru directory && set environment && exec command`.
23
+
24
+ ## Customization
25
+
26
+ This tool can provide additional information or actions through it's Web page.
27
+
28
+ ### View names and content of files that related to concrete service
29
+
30
+ For each known runit service this tool looks for **./runit-man/files-to-view/** folder.
31
+ Every symlink here will be shown as link to view target file content.
32
+
33
+ ### Show links that related to concrete service
34
+
35
+ For each known runit service this tool looks for **./runit-man/urls-to-view/** folder.
36
+ Every file ended with .url will be shown as link to view target location (location should be written as content of this file).
37
+
38
+ ### Show buttons that send signals to concrete service
39
+
40
+ For each known runit service this tool looks for **./runit-man/allowed-signals/** folder.
41
+ Each one-letter-named file declares that signal button should be shown in Web UI.
42
+
43
+ Signal letters listed below in REST API section.
44
+
45
+ ## REST API
46
+
47
+ ### Get state
48
+
49
+ You can read current state of services in [JSON format](http://www.json.org/ "JSON home page") using
50
+ `GET /services.json`
51
+
52
+ ### Management
53
+
54
+ You can manage your services using
55
+ `POST /<service name>/<command>`
56
+
57
+ Supported commands: *up*, *down*, *restart*, *switch_up* (activates service), *switch_down* (deactivates service).
58
+
59
+ You can also send any signal to service using
60
+ `POST /<service name>/signal/<signal>`
61
+
62
+ Supported signals and their's meaning:
63
+
64
+ * t: TERM
65
+ * k: KILL
66
+ * i: INT
67
+ * 1: USR1
68
+ * 2: USR2
69
+ * a: ALARM
70
+ * q: QUIT
71
+ * x: EXIT
72
+ * p: PAUSE
73
+ * c: CONT
74
+ * h: HUP
75
+ * o: ONCE
76
+
77
+ ### Read logs
78
+
79
+ #### svlogd
80
+
81
+ You can read tail of service log using
82
+ `GET /<service name>/log/<count of tailing lines>.txt`
83
+
84
+ Note that to use this feature You must do logging using
85
+ `exec svlogd options log_directory_location`
86
+
87
+ #### logger
88
+ Use logger like:
89
+ `exec logger -i -t "runit-man" -p local1.info`
90
+ and use option -l "logger:/var/log/" where base logs directory shown after period.
91
+
@@ -0,0 +1,93 @@
1
+ ## Описание
2
+
3
+ Простая утилита для управления сервисами [runit](http://smarden.org/runit/ "Домашняя страница runit") через Web-интерфейс, с поддержкой интернационализации.
4
+
5
+ Сервер запускается скриптом **runit-man**. Примите во внимание, что **runit-man** обязан иметь привилегии, аналогичные привилегиям процесса **runsvdir**.
6
+
7
+ ## Инсталляция
8
+
9
+ Обычно вам нужно поставить гемы **runit-man** и **thin** совместно, чтобы эта утилита работала эффективно.
10
+ `gem install runit-man thin`
11
+
12
+ Прагматично установить runit-man как один из сервисов runit, например, так:
13
+ `runit-man -p 14500 -r`
14
+
15
+ Эта команда создаёт сервис runit-man, как один из обычных активных сервисов runit (используя каталоги */etc/sv/* and */etc/service/* по умолчанию).
16
+
17
+ Подробнее смотрите файл INSTALL.
18
+
19
+ ### Конфигурирование под Rack
20
+
21
+ Обратите внимание, что гем runit-man gem также предоставляет файл конфигурации Rack config.ru.
22
+ Он полезен для запуска runit-man под такими серверами, как unicorn, rainbows и другими. Опция `runit-man --rackup=command` выполняет команду `cd каталог, где лежит config.ru && set environment && exec command`.
23
+
24
+ ## Кастомизация
25
+
26
+ Эта утилита способна предоставлять дополнительную информацию или действия на своей Web-странице.
27
+
28
+ ### Просмотр имён и содержимого файлов, относящихся к конкретному сервису
29
+
30
+ Для каждого известного сервиса runit эта утилита просматривает каталог **./runit-man/files-to-view/**.
31
+ Каждый симлинк в этом каталоге будет показан как ссылка на просмотр содержимого целевого файла.
32
+
33
+ ### Показ ссылок, относящихся к конкретному сервису
34
+
35
+ Для каждого известного сервиса runit эта утилита просматривает каталог **./runit-man/urls-to-view/**.
36
+ Каждый файл, имеющий расширение .url, будет показан, как сылка на просмотр целевой локации (которая берётся как содержимое файла).
37
+
38
+ ### Показ кнопок, которые посылают сигналы выбранному процессу
39
+
40
+ Для каждого известного сервиса runit эта утилита просматривает каталог **./runit-man/allowed-signals/**.
41
+ Каждый однобуквенно-именованный файл определяет, что кнопка для сигнала должна появиться в пользовательском интерфейсе.
42
+
43
+ Соответствия между буквами и сигналами перечислены ниже, в секции REST API.
44
+
45
+ ## REST API
46
+
47
+ ### Получение состояния
48
+
49
+ Вы можете получить текущее состояние сервисов в [формате JSON](http://www.json.org/ "Домашняя страница JSON"), используя
50
+ `GET /services.json`
51
+
52
+ ### Управление
53
+
54
+ Вы можете управлять вашими сервисами, используя
55
+ `POST /<service name>/<command>`
56
+
57
+ Поддерживаемые команды: *up*, *down*, *restart*, *switch_up* (активация сервиса), *switch_down* (деактивация сервиса).
58
+
59
+ Вы можете также посылать любые сигналы сервису, используя
60
+ `POST /<service name>/signal/<signal>`
61
+
62
+ Поддерживаемые сигналы и их значения:
63
+
64
+ * t: TERM
65
+ * k: KILL
66
+ * i: INT
67
+ * 1: USR1
68
+ * 2: USR2
69
+ * a: ALARM
70
+ * q: QUIT
71
+ * x: EXIT
72
+ * p: PAUSE
73
+ * c: CONT
74
+ * h: HUP
75
+ * o: ONCE
76
+
77
+ ### Чтение логов
78
+
79
+ #### svlogd
80
+
81
+ Вы можете читать хвост лога сервиса, используя
82
+ `GET /<service name>/log/<count of tailing lines>.txt`
83
+
84
+ Учитывайте, что этот функционал работает, только если Вы логгируете сервис с использованием команды вида
85
+ `exec svlogd options log_directory_location`
86
+
87
+ #### logger
88
+
89
+ Если Вы предпочитаете logger, используйте его вот так:
90
+ `exec logger -i -t "runit-man" -p local1.info`
91
+
92
+ При этом нужно использовать опцию -l "logger:/var/log/", где после двоеточия надо указывать базовый каталог логов.
93
+
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ $LOAD_PATH.unshift('./lib')
5
+
6
+ require 'runit-man/version'
7
+
8
+ begin
9
+ require 'rspec/core/rake_task'
10
+
11
+ RSpec::Core::RakeTask.new do |t|
12
+ t.rspec_opts = ["-c", "-f progress"]
13
+ end
14
+
15
+ RSpec::Core::RakeTask.new(:rcov) do |t|
16
+ t.rcov = true
17
+ t.ruby_opts = '-w'
18
+ t.rspec_opts = ["-c", "-f progress"]
19
+ t.rcov_opts = %q[-Ilib --exclude "spec/*,gems/*"]
20
+ end
21
+ rescue LoadError
22
+ $stderr.puts "RSpec not available. Install it with: gem install rspec-core rspec-expectations"
23
+ end
24
+
25
+ begin
26
+ require 'bundler'
27
+ Bundler::GemHelper.install_tasks
28
+ rescue LoadError
29
+ $stderr.puts "Bundler not available. Install it with: gem install bundler"
30
+ end
31
+
data/lib/runit-man/app.rb CHANGED
@@ -274,7 +274,7 @@ class RunitMan < Sinatra::Base
274
274
  def exec_rackup(command)
275
275
  ENV['RUNIT_ALL_SERVICES_DIR'] = RunitMan.all_services_directory
276
276
  ENV['RUNIT_ACTIVE_SERVICES_DIR'] = RunitMan.active_services_directory
277
- ENV['RUNIT_LOGGER'] = RunitMan.logger
277
+ ENV['RUNIT_LOGGER'] = RunitMan.runit_logger
278
278
  ENV['RUNIT_MAN_VIEW_FILES'] = RunitMan.files_to_view.join(',')
279
279
  ENV['RUNIT_MAN_CREDENTIALS'] = RunitMan.allowed_users.keys.map { |user| "#{user}:#{RunitMan.allowed_users[user]}" }.join(',')
280
280
 
@@ -316,10 +316,6 @@ class RunitMan < Sinatra::Base
316
316
  @allowed_users ||= {}
317
317
  end
318
318
 
319
- def logger
320
- settings.logger_option
321
- end
322
-
323
319
  def prepare_to_run
324
320
  unless allowed_users.empty?
325
321
  use Rack::Auth::Basic, 'runit-man' do |username, password|
@@ -339,8 +335,9 @@ class RunitMan < Sinatra::Base
339
335
  bind = RunitMan.respond_to?(:bind) ? RunitMan.bind : nil
340
336
  server = RunitMan.server
341
337
  files_to_view = RunitMan.files_to_view
342
- logger = RunitMan.logger
338
+ logger = RunitMan.runit_logger
343
339
  auth = RunitMan.allowed_users
340
+ rackup_command_line = RunitMan.rackup_command_line
344
341
  File.open(script_name, 'w') do |script_source|
345
342
  script_source.print ERB.new(IO.read(template_name)).result(binding())
346
343
  end
@@ -351,7 +348,7 @@ class RunitMan < Sinatra::Base
351
348
  require 'erb'
352
349
  script_name = File.join(dir, 'log', 'run')
353
350
  template_name = File.join(GEM_FOLDER, 'sv', 'log', 'run.erb')
354
- logger = RunitMan.logger
351
+ logger = RunitMan.runit_logger
355
352
  File.open(script_name, 'w') do |script_source|
356
353
  script_source.print ERB.new(IO.read(template_name)).result(binding())
357
354
  end
@@ -4,7 +4,7 @@ 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 :logger_option, ENV['RUNIT_LOGGER'] || RunitMan::DEFAULT_LOGGER
7
+ RunitMan.set :runit_logger, ENV['RUNIT_LOGGER'] || RunitMan::DEFAULT_LOGGER
8
8
 
9
9
  if ENV['RUNIT_MAN_VIEW_FILES']
10
10
  ENV['RUNIT_MAN_VIEW_FILES'].split(/\s*\,\s*/).each do |floc|
@@ -3,7 +3,8 @@ require 'runit-man/app'
3
3
 
4
4
  RunitMan.set :active_services_directory, RunitMan::DEFAULT_ACTIVE_SERVICES_DIR
5
5
  RunitMan.set :all_services_directory, RunitMan::DEFAULT_ALL_SERVICES_DIR
6
- RunitMan.set :logger_option, RunitMan::DEFAULT_LOGGER
6
+ RunitMan.set :runit_logger, RunitMan::DEFAULT_LOGGER
7
+ RunitMan.set :rackup_command_line, false
7
8
 
8
9
  OptionParser.new { |op|
9
10
  op.banner = 'Usage: runit-man <options>'
@@ -15,14 +16,14 @@ OptionParser.new { |op|
15
16
  op.separator 'runit options:'
16
17
  op.on('-a active_services_directory (/etc/service by default)') { |val| RunitMan.set :active_services_directory, val }
17
18
  op.on('-f all_services_directory (/etc/sv by default)') { |val| RunitMan.set :all_services_directory, val }
18
- op.separator 'Logger options (now svlogd and logger supported only):'
19
- op.on('-l logger application[:base folder[:priority]] (svlogd by default)') { |val| RunitMan.set :logger_option, val }
19
+ op.separator 'runit logger options (now svlogd and logger supported only):'
20
+ op.on('-l runit logger application[:base folder[:priority]] (svlogd by default)') { |val| RunitMan.set :runit_logger, val }
20
21
  op.separator 'View options:'
21
22
  op.on('-v file_location', 'Enables view of specified file through runit-man') { |val| RunitMan.enable_view_of(val) }
22
23
  op.on('-u user:password', 'Requires user name with given password to auth') { |val| RunitMan.add_user(*(val.split(':', 2))) }
23
24
  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)
25
+ op.on('--rackup command_line', 'Change directory to config.ru location, set environment by options and execute specified command_line') do |command_line|
26
+ RunitMan.set :rackup_command_line, command_line
26
27
  end
27
28
  op.on_tail('-r', '--register', 'Register as runit service') do
28
29
  RunitMan.register_as_runit_service
@@ -30,6 +31,10 @@ OptionParser.new { |op|
30
31
  end
31
32
  }.parse!(ARGV.dup)
32
33
 
34
+ if RunitMan.rackup_command_line
35
+ RunitMan.exec_rackup(RunitMan.rackup_command_line)
36
+ end
37
+
33
38
  RunitMan.prepare_to_run
34
39
 
35
40
  RunitMan.run!
@@ -120,7 +120,7 @@ class ServiceInfo
120
120
  end
121
121
 
122
122
  def log_file_path(file_name)
123
- case RunitMan.logger
123
+ case RunitMan.runit_logger
124
124
  when RunitMan::DEFAULT_LOGGER then svlogd_log_file_path(file_name)
125
125
  when /^logger(?:\:.+)?/ then logger_log_file_path(file_name)
126
126
  else nil
@@ -185,7 +185,7 @@ class ServiceInfo
185
185
  end
186
186
 
187
187
  def log_files
188
- case RunitMan.logger
188
+ case RunitMan.runit_logger
189
189
  when RunitMan::DEFAULT_LOGGER then svlogd_log_files
190
190
  when /^logger(?:\:.+)?/ then logger_log_files
191
191
  else []
@@ -286,7 +286,7 @@ private
286
286
  end
287
287
 
288
288
  def log_location_cache
289
- @log_location_cache ||= LogLocationCache.new(RunitMan.logger)
289
+ @log_location_cache ||= LogLocationCache.new(RunitMan.runit_logger)
290
290
  end
291
291
 
292
292
  def real_data_from_file(file_name)
@@ -1,5 +1,5 @@
1
1
  module RunitManVersion
2
- VERSION = '2.3.6'.freeze
2
+ VERSION = '2.3.7'.freeze
3
3
 
4
4
  class << self
5
5
  attr_accessor :sendfile
data/local-run.rb ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
5
+
6
+ require 'runit-man/runner'
data/runit-man.gemspec ADDED
@@ -0,0 +1,34 @@
1
+ $LOAD_PATH.unshift File.expand_path('./lib', File.dirname(__FILE__))
2
+ require 'runit-man/version'
3
+
4
+ spec = Gem::Specification.new do |s|
5
+ s.platform = Gem::Platform::RUBY
6
+ s.summary = "Runit web management tool."
7
+ s.name = 'runit-man'
8
+ s.author = 'Akzhan Abdulin'
9
+ s.email = 'akzhan.abdulin@gmail.com'
10
+ s.date = Time.now.strftime('%Y-%m-%d')
11
+ s.homepage = 'https://github.com/Undev/runit-man'
12
+ s.version = RunitManVersion::VERSION.dup
13
+ s.requirements << 'none'
14
+ s.require_path = 'lib'
15
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
16
+ s.extra_rdoc_files = [
17
+ "README.markdown"
18
+ ]
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.add_dependency 'yajl-ruby', '>= 0.7.8'
22
+ s.add_dependency 'haml', '>= 3.0'
23
+ s.add_dependency 'sinatra', '>= 1.1'
24
+ s.add_dependency 'sinatra-content-for2', '>= 0.2.4'
25
+ s.add_dependency 'i18n', '>= 0.5.0'
26
+ s.add_dependency 'file-tail', '>= 1.0.5'
27
+ s.add_development_dependency 'rspec-core'
28
+ s.add_development_dependency 'rspec-expectations'
29
+ s.add_development_dependency 'rr'
30
+ s.add_development_dependency 'rack-test'
31
+ s.add_development_dependency 'bundler', '>= 1.0.10'
32
+ s.description = File.open(File.join(File.dirname(__FILE__), 'DESCRIPTION')).read
33
+ end
34
+
data/script/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ SINATRA_ROOT = File.expand_path('..', File.dirname(__FILE__))
4
+
5
+ irb = (RUBY_PLATFORM =~ /(:?mswin|mingw)/) ? 'irb.bat' : 'irb'
6
+
7
+ exec("#{irb} --readline -I #{SINATRA_ROOT}/lib -r irb/completion --prompt-mode simple -r rubygems -r runit-man/app")
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe RunitMan do
4
+ def app
5
+ RunitMan
6
+ end
7
+
8
+ it "should respond to /" do
9
+ get '/'
10
+ last_response.should be_ok
11
+ end
12
+
13
+ it "should respond to /services" do
14
+ stub(ServiceInfo).all { [] }
15
+
16
+ get '/services'
17
+ last_response.should be_ok
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'runit-man', 'app')
2
+
3
+ require 'rack/test'
4
+ require 'rspec'
5
+
6
+ class RunitMan
7
+ # set test environment
8
+ set :environment, :test
9
+ set :raise_errors, true
10
+ set :logging, false
11
+ end
12
+
13
+ RSpec.configure do |conf|
14
+ conf.mock_with :rr
15
+ conf.include Rack::Test::Methods
16
+ end
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}\"" : '' %>
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 %>
4
4
 
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: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 3
9
- - 6
10
- version: 2.3.6
9
+ - 7
10
+ version: 2.3.7
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-06-02 00:00:00 +04:00
18
+ date: 2011-06-23 00:00:00 +04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -196,10 +196,21 @@ executables:
196
196
  - runit-man
197
197
  extensions: []
198
198
 
199
- extra_rdoc_files: []
200
-
199
+ extra_rdoc_files:
200
+ - README.markdown
201
201
  files:
202
+ - .gitignore
203
+ - CHANGELOG.markdown
204
+ - DESCRIPTION
205
+ - Gemfile
206
+ - INSTALL
207
+ - LICENSE
208
+ - README.markdown
209
+ - README_ru.markdown
210
+ - Rakefile
202
211
  - bin/runit-man
212
+ - i18n/en.yml
213
+ - i18n/ru.yml
203
214
  - lib/runit-man/app.rb
204
215
  - lib/runit-man/config.ru
205
216
  - lib/runit-man/helpers.rb
@@ -211,6 +222,7 @@ files:
211
222
  - lib/runit-man/service_status.rb
212
223
  - lib/runit-man/utils.rb
213
224
  - lib/runit-man/version.rb
225
+ - local-run.rb
214
226
  - public/css/runit-man.css
215
227
  - public/css/tripoli.simple.css
216
228
  - public/css/tripoli.simple.ie.css
@@ -219,6 +231,12 @@ files:
219
231
  - public/favicon.ico
220
232
  - public/js/jquery-1.6.1.min.js
221
233
  - public/js/runit-man.js
234
+ - runit-man.gemspec
235
+ - script/console
236
+ - spec/functional/runit-man_spec.rb
237
+ - spec/spec_helper.rb
238
+ - sv/log/run.erb
239
+ - sv/run.erb
222
240
  - views/_service_action.haml
223
241
  - views/_service_info.haml
224
242
  - views/_service_signal.haml
@@ -229,10 +247,6 @@ files:
229
247
  - views/log.haml
230
248
  - views/log_downloads.haml
231
249
  - views/view_file.haml
232
- - i18n/en.yml
233
- - i18n/ru.yml
234
- - sv/log/run.erb
235
- - sv/run.erb
236
250
  has_rdoc: true
237
251
  homepage: https://github.com/Undev/runit-man
238
252
  licenses: []
@@ -267,5 +281,6 @@ rubygems_version: 1.5.2
267
281
  signing_key:
268
282
  specification_version: 3
269
283
  summary: Runit web management tool.
270
- test_files: []
271
-
284
+ test_files:
285
+ - spec/functional/runit-man_spec.rb
286
+ - spec/spec_helper.rb