runit-man 1.6.1 → 1.6.2
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.
- data/lib/runit-man/app.rb +27 -20
- metadata +2 -2
data/lib/runit-man/app.rb
CHANGED
@@ -82,27 +82,34 @@ class RunitMan < Sinatra::Base
|
|
82
82
|
data[:text]
|
83
83
|
end
|
84
84
|
|
85
|
-
|
85
|
+
def data_of_file_view(request)
|
86
86
|
if !request.GET.has_key?('file')
|
87
|
+
return nil
|
88
|
+
end
|
89
|
+
file_path = request.GET['file']
|
90
|
+
return nil unless files_to_view.include?(file_path)
|
91
|
+
{
|
92
|
+
:name => file_path,
|
93
|
+
:text => IO.read(file_path)
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
97
|
+
get '/view' do
|
98
|
+
data = data_of_file_view(request)
|
99
|
+
if data.nil?
|
87
100
|
return not_found
|
88
101
|
end
|
89
|
-
f = request.GET['file']
|
90
|
-
return not_found unless all_files_to_view.include?(f)
|
91
102
|
@scripts = []
|
92
|
-
@title = t.runit.view_file.title(h(
|
93
|
-
erb :view_file, :locals =>
|
94
|
-
:name => f,
|
95
|
-
:text => IO.read(f)
|
96
|
-
}
|
103
|
+
@title = t.runit.view_file.title(h(data[:name]), h(host_name))
|
104
|
+
erb :view_file, :locals => data
|
97
105
|
end
|
98
106
|
|
99
107
|
get '/view.txt' do
|
100
|
-
|
108
|
+
data = data_of_file_view(request)
|
109
|
+
if data.nil?
|
101
110
|
return not_found
|
102
111
|
end
|
103
|
-
|
104
|
-
return not_found unless files_to_view.include?(f)
|
105
|
-
IO.read(f)
|
112
|
+
data[:text]
|
106
113
|
end
|
107
114
|
|
108
115
|
def log_action(name, text)
|
@@ -112,18 +119,18 @@ class RunitMan < Sinatra::Base
|
|
112
119
|
end
|
113
120
|
|
114
121
|
post '/:name/signal/:signal' do |name, signal|
|
115
|
-
|
116
|
-
return not_found if
|
117
|
-
|
122
|
+
service = ServiceInfo[name]
|
123
|
+
return not_found if service.nil?
|
124
|
+
service.send_signal(signal)
|
118
125
|
log_action(name, "send signal \"#{signal}\"")
|
119
126
|
''
|
120
127
|
end
|
121
128
|
|
122
129
|
post '/:name/:action' do |name, action|
|
123
|
-
|
130
|
+
service = ServiceInfo[name]
|
124
131
|
action = "#{action}!".to_sym
|
125
|
-
return not_found if
|
126
|
-
|
132
|
+
return not_found if service.nil? || !service.respond_to?(action)
|
133
|
+
service.send(action)
|
127
134
|
log_action(name, action)
|
128
135
|
''
|
129
136
|
end
|
@@ -159,8 +166,8 @@ class RunitMan < Sinatra::Base
|
|
159
166
|
def create_run_script(dir)
|
160
167
|
script_name = File.join(dir, 'run')
|
161
168
|
template_name = File.join(GEM_FOLDER, 'sv', 'run.erb')
|
162
|
-
File.open(script_name, 'w') do |
|
163
|
-
|
169
|
+
File.open(script_name, 'w') do |script_source|
|
170
|
+
script_source.print Erubis::Eruby.new(IO.read(template_name)).result(
|
164
171
|
:all_services_directory => RunitMan.all_services_directory,
|
165
172
|
:active_services_directory => RunitMan.active_services_directory,
|
166
173
|
:port => RunitMan.port,
|