renamed execute_websocket_command to open_websocket_connection, because we now run the command after all listeners in the submissions controller were attached
This commit is contained in:
@ -111,6 +111,7 @@ class SubmissionsController < ApplicationController
|
||||
|
||||
if result[:status] == :container_running
|
||||
socket = result[:socket]
|
||||
command = result[:command]
|
||||
|
||||
socket.on :message do |event|
|
||||
Rails.logger.info( Time.now.getutc.to_s + ": Docker sending: " + event.data)
|
||||
@ -139,6 +140,11 @@ class SubmissionsController < ApplicationController
|
||||
Rails.logger.debug('Rescued parsing error, sent the received client data to docker:' + data)
|
||||
end
|
||||
end
|
||||
|
||||
# Send command after all listeners are attached.
|
||||
# Newline required to flush
|
||||
socket.send command + "\n"
|
||||
Rails.logger.info('Sent command: ' + command.to_s)
|
||||
else
|
||||
kill_socket(tubesock)
|
||||
end
|
||||
|
@ -218,7 +218,7 @@ class DockerClient
|
||||
end
|
||||
|
||||
#called when the user clicks the "Run" button
|
||||
def execute_websocket_command(command, before_execution_block, output_consuming_block)
|
||||
def open_websocket_connection(command, before_execution_block, output_consuming_block)
|
||||
@container = DockerContainerPool.get_container(@execution_environment)
|
||||
if @container
|
||||
@container.status = :executing
|
||||
@ -231,10 +231,7 @@ class DockerClient
|
||||
end
|
||||
# TODO: catch exception if socket could not be created
|
||||
@socket ||= create_socket(@container)
|
||||
# Newline required to flush
|
||||
@socket.send command + "\n"
|
||||
Rails.logger.info('Sent command: ' + command.to_s)
|
||||
{status: :container_running, socket: @socket, container: @container}
|
||||
{status: :container_running, socket: @socket, container: @container, command: command}
|
||||
else
|
||||
{status: :container_depleted}
|
||||
end
|
||||
@ -297,7 +294,8 @@ class DockerClient
|
||||
"""
|
||||
command = submission.execution_environment.run_command % command_substitutions(filename)
|
||||
create_workspace_files = proc { create_workspace_files(container, submission) }
|
||||
execute_websocket_command(command, create_workspace_files, block)
|
||||
open_websocket_connection(command, create_workspace_files, block)
|
||||
# actual run command is run in the submissions controller, after all listeners are attached.
|
||||
end
|
||||
|
||||
def execute_test_command(submission, filename, &block)
|
||||
|
Reference in New Issue
Block a user