runit-man 1.5.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/runit-man/app.rb +12 -6
- data/sv/run.erb +0 -1
- metadata +2 -2
data/lib/runit-man/app.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'ftools'
|
1
2
|
require 'json'
|
2
3
|
require 'erubis'
|
3
4
|
require 'sinatra/base'
|
@@ -129,14 +130,18 @@ class RunitMan < Sinatra::Base
|
|
129
130
|
|
130
131
|
class << self
|
131
132
|
def register_as_runit_service
|
132
|
-
create_run_script
|
133
133
|
all_r_dir = File.join(RunitMan.all_services_directory, 'runit-man')
|
134
134
|
active_r_dir = File.join(RunitMan.active_services_directory, 'runit-man')
|
135
135
|
my_dir = File.join(GEM_FOLDER, 'sv')
|
136
|
+
log_dir = File.join(all_r_dir, 'log')
|
136
137
|
if File.symlink?(all_r_dir)
|
137
138
|
File.unlink(all_r_dir)
|
138
139
|
end
|
139
|
-
File.
|
140
|
+
unless File.directory?(all_r_dir)
|
141
|
+
File.makedirs(log_dir)
|
142
|
+
File.copy(File.join(my_dir, 'log', 'run'), File.join(log_dir, 'run'))
|
143
|
+
end
|
144
|
+
create_run_script(all_r_dir)
|
140
145
|
unless File.symlink?(active_r_dir)
|
141
146
|
File.symlink(all_r_dir, active_r_dir)
|
142
147
|
end
|
@@ -151,10 +156,11 @@ class RunitMan < Sinatra::Base
|
|
151
156
|
end
|
152
157
|
|
153
158
|
private
|
154
|
-
def create_run_script
|
155
|
-
script_name
|
156
|
-
File.
|
157
|
-
|
159
|
+
def create_run_script(dir)
|
160
|
+
script_name = File.join(dir, 'run')
|
161
|
+
template_name = File.join(GEM_FOLDER, 'sv', 'run.erb')
|
162
|
+
File.open(script_name, 'w') do |handle|
|
163
|
+
handle.print Erubis::Eruby.new(IO.read(template_name)).result(
|
158
164
|
:all_services_directory => RunitMan.all_services_directory,
|
159
165
|
:active_services_directory => RunitMan.active_services_directory,
|
160
166
|
:port => RunitMan.port,
|
data/sv/run.erb
CHANGED
@@ -2,4 +2,3 @@
|
|
2
2
|
exec 2>&1
|
3
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 %>
|
4
4
|
|
5
|
-
<%= files_to_view.join(',') %>
|