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)
|
||||
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
|
||||
# copy each annotation and set the target_file.id
|
||||
unless(params[:annotations_arr].nil?)
|
||||
@@ -88,6 +93,11 @@ class SubmissionsController < ApplicationController
|
||||
# end
|
||||
|
||||
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?
|
||||
|
||||
|
||||
@@ -122,11 +132,11 @@ class SubmissionsController < ApplicationController
|
||||
@docker_client.exit_container(result[:container])
|
||||
else
|
||||
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
|
||||
rescue JSON::ParserError
|
||||
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
|
||||
else
|
||||
@@ -147,8 +157,8 @@ class SubmissionsController < ApplicationController
|
||||
kill_socket(tubesock)
|
||||
else
|
||||
# Filter out information about run_command, test_command, user or working directory
|
||||
run_command = @submission.execution_environment.run_command
|
||||
test_command = @submission.execution_environment.test_command
|
||||
run_command = @submission.execution_environment.run_command % command_substitutions(params[:filename])
|
||||
test_command = @submission.execution_environment.test_command % command_substitutions(params[:filename])
|
||||
if !(/root|workspace|#{run_command}|#{test_command}/.match(message))
|
||||
parse_message(message, 'stdout', tubesock)
|
||||
end
|
||||
|
Reference in New Issue
Block a user