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.
Files changed (3) hide show
  1. data/lib/runit-man/app.rb +12 -6
  2. data/sv/run.erb +0 -1
  3. 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.symlink(my_dir, all_r_dir)
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 = File.join(GEM_FOLDER, 'sv', 'run')
156
- File.open(script_name, 'w') do |f|
157
- f.print Erubis::Eruby.new(IO.read(script_name + '.erb')).result(
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(',') %>
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 5
8
- - 3
9
- version: 1.5.3
8
+ - 4
9
+ version: 1.5.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Akzhan Abdulin