six-updater-web 0.14.9 → 0.14.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/six-updater-web/app/controllers/logviews_controller.rb +1 -1
- data/lib/six-updater-web/app/models/sixconfig.rb +69 -7
- data/lib/six-updater-web/app/views/main/logoutput.erb +1 -1
- data/lib/six-updater-web/config/six-updater-web.rb +1 -1
- data/lib/six-updater-web/lib/wrapper.rb +3 -0
- metadata +4 -3
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ class LogviewsController < ApplicationController
|
|
12
12
|
def upd
|
13
13
|
s = Log.find(:last, :select => "id,updated_at")
|
14
14
|
s = Log.new unless s
|
15
|
-
logger.debug "Latest entry: #{s}"
|
15
|
+
logger.debug "Latest entry: #{s.id}"
|
16
16
|
|
17
17
|
#session[:logentry] = 0 unless session[:logentry]
|
18
18
|
# Cache'll loop :D
|
@@ -148,6 +148,9 @@ class Sixconfig < ActiveRecord::Base
|
|
148
148
|
previous_r
|
149
149
|
end
|
150
150
|
|
151
|
+
# TODO: On Windows, use the wrapper, and SIX-SHEBANG
|
152
|
+
# While on linux we could simply use normal IO.popen as the exitstatus is fine there?
|
153
|
+
|
151
154
|
# TODO: FIXME, Can't run this in development atm!
|
152
155
|
def self.start_updater_inweb(cli)
|
153
156
|
logger.info "Starting #{exec} with #{cli} from #{SixUpdaterWeb::BASE_PATH}"
|
@@ -160,10 +163,20 @@ class Sixconfig < ActiveRecord::Base
|
|
160
163
|
ses.save
|
161
164
|
ses = ses.id # Workaround for some issue with throwing around this record, in development mode.
|
162
165
|
messages, buff = [], []
|
166
|
+
shebang = nil
|
163
167
|
found_r, previous_r = nil, nil
|
168
|
+
status = nil
|
169
|
+
cmd = case RUBY_PLATFORM
|
170
|
+
when /-mingw32$/, /-mswin32$/
|
171
|
+
"ruby \"#{File.join(RAILS_ROOT, "lib", "wrapper.rb")}\" #{exec} #{cl}"
|
172
|
+
else
|
173
|
+
"#{exec} #{cl}"
|
174
|
+
end
|
175
|
+
|
164
176
|
begin
|
165
|
-
status = Open3.popen3("#{exec} #{cl}") do |io_in, io_out, io_err, waitth|
|
177
|
+
status = IO.popen(cmd) do |io_out| #Open3.popen3("#{exec} #{cl}") do |io_in, io_out, io_err, waitth|
|
166
178
|
previous = Time.now
|
179
|
+
#io_in.close
|
167
180
|
io_out.sync = true
|
168
181
|
io_out.each_byte do |b|
|
169
182
|
begin
|
@@ -178,12 +191,20 @@ class Sixconfig < ActiveRecord::Base
|
|
178
191
|
buff << char
|
179
192
|
msg = buff.join("")
|
180
193
|
buff = []
|
181
|
-
|
194
|
+
if msg =~ /^SIX-SHEBANG: /
|
195
|
+
shebang = msg
|
196
|
+
else
|
197
|
+
previous_r = process_msg(msg, messages, ses, previous_r)
|
198
|
+
end
|
182
199
|
else
|
183
200
|
# Other char; Process buffer, then add it to a new buffer
|
184
201
|
msg = buff.join("")
|
185
202
|
buff = []
|
186
|
-
|
203
|
+
if msg =~ /^SIX-SHEBANG: /
|
204
|
+
shebang = msg
|
205
|
+
else
|
206
|
+
previous_r = process_msg(msg, messages, ses, previous_r)
|
207
|
+
end
|
187
208
|
found_r = true if ["\r"].include?(char)
|
188
209
|
buff << char
|
189
210
|
end
|
@@ -196,7 +217,11 @@ class Sixconfig < ActiveRecord::Base
|
|
196
217
|
when "\n"
|
197
218
|
msg = buff.join("")
|
198
219
|
buff = []
|
199
|
-
|
220
|
+
if msg =~ /^SIX-SHEBANG: /
|
221
|
+
shebang = msg
|
222
|
+
else
|
223
|
+
previous_r = process_msg(msg, messages, ses, previous_r)
|
224
|
+
end
|
200
225
|
end
|
201
226
|
end
|
202
227
|
else
|
@@ -205,7 +230,11 @@ class Sixconfig < ActiveRecord::Base
|
|
205
230
|
if ["\r","\n"].include?(char)
|
206
231
|
msg = buff.join("")
|
207
232
|
buff = []
|
208
|
-
|
233
|
+
#if msg =~ /^SIX-SHEBANG: /
|
234
|
+
# shebang = msg
|
235
|
+
#else
|
236
|
+
previous_r = process_msg(msg, messages, ses, previous_r)
|
237
|
+
#end
|
209
238
|
end
|
210
239
|
end
|
211
240
|
rescue => e
|
@@ -226,13 +255,46 @@ class Sixconfig < ActiveRecord::Base
|
|
226
255
|
end
|
227
256
|
end
|
228
257
|
end
|
258
|
+
#status = waitth.value
|
229
259
|
end
|
230
260
|
rescue => e
|
231
261
|
backtrace(e, log)
|
232
262
|
end
|
233
263
|
|
234
|
-
|
235
|
-
|
264
|
+
pid, status = nil, 1
|
265
|
+
case RUBY_PLATFORM
|
266
|
+
when /-mingw32$/, /-mswin32$/
|
267
|
+
# Handle last bits in the buffer
|
268
|
+
unless buff.empty?
|
269
|
+
msg = buff.join("")
|
270
|
+
if msg =~ /^SIX-SHEBANG: /
|
271
|
+
shebang = msg
|
272
|
+
else
|
273
|
+
previous_r = process_msg(msg, messages, ses, previous_r)
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
# Handle status and pid
|
278
|
+
if shebang
|
279
|
+
shebang[/^SIX-SHEBANG: ([0-9]*), ([0-9]*)/]
|
280
|
+
pid, status = $1.to_i, $2.to_i
|
281
|
+
end
|
282
|
+
else
|
283
|
+
# Handle last bits in the buffer
|
284
|
+
unless buff.empty?
|
285
|
+
msg = buff.join("")
|
286
|
+
previous_r = process_msg(msg, messages, ses, previous_r)
|
287
|
+
end
|
288
|
+
|
289
|
+
# Handle status and pid
|
290
|
+
pid, status = $?.pid, $?.exitstatus
|
291
|
+
end
|
292
|
+
|
293
|
+
if status > 0
|
294
|
+
messages << Log.new(:logsession_id => ses, :content => "Abnormal program termination. #{pid}: #{status}")
|
295
|
+
else
|
296
|
+
messages << Log.new(:logsession_id => ses, :content => "Normal program termination. #{pid}: #{status}")
|
297
|
+
end
|
236
298
|
|
237
299
|
unless messages.empty?
|
238
300
|
begin
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%#= periodically_call_remote(:url => 'log', :frequency => '1', :update => 'log') %>
|
2
|
-
<%= periodically_call_remote(:url => '/logviews/upd', :frequency => '
|
2
|
+
<%= periodically_call_remote(:url => '/logviews/upd', :frequency => '4') %>
|
3
3
|
|
4
4
|
<b>This page auto refreshes, please close this page after finished reading</b><br />
|
5
5
|
<%= link_to "Mod Changelogs", :controller => :main, :action => :modlogs %><br />
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 14
|
8
|
-
-
|
9
|
-
version: 0.14.
|
8
|
+
- 10
|
9
|
+
version: 0.14.10
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sickboy
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-09 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -218,6 +218,7 @@ files:
|
|
218
218
|
- lib/six-updater-web/init.rb
|
219
219
|
- lib/six-updater-web/lib/tasks/fixtures.rake
|
220
220
|
- lib/six-updater-web/lib/tasks/sync.rake
|
221
|
+
- lib/six-updater-web/lib/wrapper.rb
|
221
222
|
- lib/six-updater-web/log/production.log
|
222
223
|
- lib/six-updater-web/public/404.html
|
223
224
|
- lib/six-updater-web/public/422.html
|