runit-man 1.2 → 1.3

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.
Files changed (4) hide show
  1. data/bin/runit-man.rb +4 -0
  2. data/lib/runit-man/app.rb +18 -2
  3. data/sv/run +1 -1
  4. metadata +22 -5
data/bin/runit-man.rb CHANGED
@@ -14,6 +14,10 @@ OptionParser.new { |op|
14
14
  op.on('-b addr') { |val| RunitMan.set :bind, val }
15
15
  op.on('-a active_services_directory (/etc/service by default)') { |val| RunitMan.set :active_services_directory, val }
16
16
  op.on('-f all_services_directory (/etc/sv by default)') { |val| RunitMan.set :all_services_directory, val }
17
+ op.on_tail('-r', '--register', 'Register as runit service') do
18
+ RunitMan.register_as_runit_service
19
+ exit
20
+ end
17
21
  }.parse!(ARGV.dup)
18
22
 
19
23
  RunitMan.run!
data/lib/runit-man/app.rb CHANGED
@@ -8,6 +8,8 @@ require 'runit-man/helpers'
8
8
 
9
9
  R18n::Filters.on :variables
10
10
 
11
+ GEM_FOLDER = File.expand_path(File.join('..', '..'), File.dirname(__FILE__)).freeze
12
+
11
13
  CONTENT_TYPES = {
12
14
  :html => 'text/html',
13
15
  :css => 'text/css',
@@ -22,7 +24,7 @@ class RunitMan < Sinatra::Base
22
24
  set :logging, true
23
25
  set :dump_errors, true
24
26
  set :raise_errors, false
25
- set :root, File.expand_path(File.join('..', '..'), File.dirname(__FILE__))
27
+ set :root, GEM_FOLDER
26
28
 
27
29
  register Sinatra::R18n
28
30
 
@@ -62,7 +64,8 @@ class RunitMan < Sinatra::Base
62
64
  end
63
65
 
64
66
  def log_action(name, text)
65
- addr = request.env.include?('X_REAL_IP') ? request.env['X_REAL_IP'] : request.env['REMOTE_ADDR']
67
+ env = request.env
68
+ addr = env.include?('X_REAL_IP') ? env['X_REAL_IP'] : env['REMOTE_ADDR']
66
69
  puts "#{addr} - - [#{Time.now}] \"Do #{text} on #{name}\""
67
70
  end
68
71
 
@@ -74,4 +77,17 @@ class RunitMan < Sinatra::Base
74
77
  log_action(name, action)
75
78
  ''
76
79
  end
80
+
81
+ class << self
82
+ def register_as_runit_service
83
+ return if File.symlink?(File.join(RunitMan.all_services_directory, 'runit-man'))
84
+ do_cmd("ln -sf #{File.join(GEM_FOLDER, 'sv')} #{File.join(RunitMan.all_services_directory, 'runit-man')}")
85
+ do_cmd("ln -sf #{File.join(RunitMan.all_services_directory, 'runit-man')} #{File.join(RunitMan.active_services_directory, 'runit-man')}")
86
+ end
87
+
88
+ private
89
+ def do_cmd(command)
90
+ system(command) or raise "Cannot execute #{command}"
91
+ end
92
+ end
77
93
  end
data/sv/run CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/bin/sh
2
2
  exec 2>&1
3
- exec runit-man.rb -p 14230
3
+ exec runit-man.rb -b 127.0.0.1 -p 12343
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runit-man
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.2"
4
+ version: "1.3"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akzhan Abdulin
@@ -92,9 +92,26 @@ dependencies:
92
92
  - !ruby/object:Gem::Version
93
93
  version: "0"
94
94
  version:
95
- description: |
96
- runit-man is simple web frontend for runit.
97
-
95
+ description: |+
96
+ Simple runit web management tool.
97
+
98
+ Server will run by runit-man.rb script.
99
+
100
+ Take a look at its options:
101
+ -p - Port to listen (4567 by default)
102
+ -b - IP Address to bind (0.0.0.0 by default)
103
+ -a - Directory of activated services (/etc/service by default)
104
+ -f - Directory of all known services (/etc/sv by default)
105
+ -r - Register runit-man as runit service (127.0.0.1:12343 by default)
106
+
107
+ Usually you need thin or mongrel gem to run runit-man fine.
108
+ gem install thin
109
+
110
+ Any localization can be done by editing of ./i18n/*.yml locale files.
111
+
112
+ Yours sincerely,
113
+ Akzhan.
114
+
98
115
  email: akzhan.abdulin@gmail.com
99
116
  executables:
100
117
  - runit-man.rb
@@ -128,7 +145,7 @@ files:
128
145
  - sv/run
129
146
  - sv/log/run
130
147
  has_rdoc: true
131
- homepage:
148
+ homepage: http://github.com/akzhan/runit-man
132
149
  licenses: []
133
150
 
134
151
  post_install_message: