changed position of saving the run output, so it catches timeouts as well
This commit is contained in:
@ -143,7 +143,7 @@ class SubmissionsController < ApplicationController
|
|||||||
tubesock.onmessage do |data|
|
tubesock.onmessage do |data|
|
||||||
Rails.logger.info(Time.now.getutc.to_s + ": Client sending: " + data)
|
Rails.logger.info(Time.now.getutc.to_s + ": Client sending: " + data)
|
||||||
# Check whether the client send a JSON command and kill container
|
# Check whether the client send a JSON command and kill container
|
||||||
# if the command is 'client_exit', send it to docker otherwise.
|
# if the command is 'client_kill', send it to docker otherwise.
|
||||||
begin
|
begin
|
||||||
parsed = JSON.parse(data)
|
parsed = JSON.parse(data)
|
||||||
if parsed['cmd'] == 'client_kill'
|
if parsed['cmd'] == 'client_kill'
|
||||||
@ -170,6 +170,9 @@ class SubmissionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def kill_socket(tubesock)
|
def kill_socket(tubesock)
|
||||||
|
# save the output of this "run" as a "testrun" (scoring runs are saved in submission_scoring.rb)
|
||||||
|
save_run_output
|
||||||
|
|
||||||
# Hijacked connection needs to be notified correctly
|
# Hijacked connection needs to be notified correctly
|
||||||
tubesock.send_data JSON.dump({'cmd' => 'exit'})
|
tubesock.send_data JSON.dump({'cmd' => 'exit'})
|
||||||
tubesock.close
|
tubesock.close
|
||||||
@ -238,6 +241,12 @@ class SubmissionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def save_run_output
|
||||||
|
if !@message_buffer.blank?
|
||||||
|
Testrun.create(file: @file, submission: @submission, output: @message_buffer)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def score
|
def score
|
||||||
hijack do |tubesock|
|
hijack do |tubesock|
|
||||||
Thread.new { EventMachine.run } unless EventMachine.reactor_running? && EventMachine.reactor_thread.alive?
|
Thread.new { EventMachine.run } unless EventMachine.reactor_running? && EventMachine.reactor_thread.alive?
|
||||||
|
Reference in New Issue
Block a user