Hide parametrized run and test commands. Some logging changes, comment on possible thread code to release database connections, not sure whether necessary.
This commit is contained in:
@@ -25,6 +25,11 @@ class SubmissionsController < ApplicationController
|
|||||||
create_and_respond(object: @submission)
|
create_and_respond(object: @submission)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def command_substitutions(filename)
|
||||||
|
{class_name: File.basename(filename, File.extname(filename)).camelize, filename: filename, module_name: File.basename(filename, File.extname(filename)).underscore}
|
||||||
|
end
|
||||||
|
private :command_substitutions
|
||||||
|
|
||||||
def copy_comments
|
def copy_comments
|
||||||
# copy each annotation and set the target_file.id
|
# copy each annotation and set the target_file.id
|
||||||
unless(params[:annotations_arr].nil?)
|
unless(params[:annotations_arr].nil?)
|
||||||
@@ -88,6 +93,11 @@ class SubmissionsController < ApplicationController
|
|||||||
# end
|
# end
|
||||||
|
|
||||||
hijack do |tubesock|
|
hijack do |tubesock|
|
||||||
|
# probably add:
|
||||||
|
# ensure
|
||||||
|
# #guarantee that the thread is releasing the DB connection after it is done
|
||||||
|
# ActiveRecord::Base.connectionpool.releaseconnection
|
||||||
|
# end
|
||||||
Thread.new { EventMachine.run } unless EventMachine.reactor_running? && EventMachine.reactor_thread.alive?
|
Thread.new { EventMachine.run } unless EventMachine.reactor_running? && EventMachine.reactor_thread.alive?
|
||||||
|
|
||||||
|
|
||||||
@@ -122,11 +132,11 @@ class SubmissionsController < ApplicationController
|
|||||||
@docker_client.exit_container(result[:container])
|
@docker_client.exit_container(result[:container])
|
||||||
else
|
else
|
||||||
socket.send data
|
socket.send data
|
||||||
Rails.logger.info('Sent the received data to docker:' + data)
|
Rails.logger.debug('Sent the received client data to docker:' + data)
|
||||||
end
|
end
|
||||||
rescue JSON::ParserError
|
rescue JSON::ParserError
|
||||||
socket.send data
|
socket.send data
|
||||||
Rails.logger.info('Sent the received data to docker:' + data)
|
Rails.logger.debug('Rescued parsing error, sent the received client data to docker:' + data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -147,8 +157,8 @@ class SubmissionsController < ApplicationController
|
|||||||
kill_socket(tubesock)
|
kill_socket(tubesock)
|
||||||
else
|
else
|
||||||
# Filter out information about run_command, test_command, user or working directory
|
# Filter out information about run_command, test_command, user or working directory
|
||||||
run_command = @submission.execution_environment.run_command
|
run_command = @submission.execution_environment.run_command % command_substitutions(params[:filename])
|
||||||
test_command = @submission.execution_environment.test_command
|
test_command = @submission.execution_environment.test_command % command_substitutions(params[:filename])
|
||||||
if !(/root|workspace|#{run_command}|#{test_command}/.match(message))
|
if !(/root|workspace|#{run_command}|#{test_command}/.match(message))
|
||||||
parse_message(message, 'stdout', tubesock)
|
parse_message(message, 'stdout', tubesock)
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user