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
|
if result[:status] == :container_running
|
||||||
socket = result[:socket]
|
socket = result[:socket]
|
||||||
|
command = result[:command]
|
||||||
|
|
||||||
socket.on :message do |event|
|
socket.on :message do |event|
|
||||||
Rails.logger.info( Time.now.getutc.to_s + ": Docker sending: " + event.data)
|
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)
|
Rails.logger.debug('Rescued parsing error, sent the received client data to docker:' + data)
|
||||||
end
|
end
|
||||||
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
|
else
|
||||||
kill_socket(tubesock)
|
kill_socket(tubesock)
|
||||||
end
|
end
|
||||||
|
@ -218,7 +218,7 @@ class DockerClient
|
|||||||
end
|
end
|
||||||
|
|
||||||
#called when the user clicks the "Run" button
|
#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)
|
@container = DockerContainerPool.get_container(@execution_environment)
|
||||||
if @container
|
if @container
|
||||||
@container.status = :executing
|
@container.status = :executing
|
||||||
@ -231,10 +231,7 @@ class DockerClient
|
|||||||
end
|
end
|
||||||
# TODO: catch exception if socket could not be created
|
# TODO: catch exception if socket could not be created
|
||||||
@socket ||= create_socket(@container)
|
@socket ||= create_socket(@container)
|
||||||
# Newline required to flush
|
{status: :container_running, socket: @socket, container: @container, command: command}
|
||||||
@socket.send command + "\n"
|
|
||||||
Rails.logger.info('Sent command: ' + command.to_s)
|
|
||||||
{status: :container_running, socket: @socket, container: @container}
|
|
||||||
else
|
else
|
||||||
{status: :container_depleted}
|
{status: :container_depleted}
|
||||||
end
|
end
|
||||||
@ -297,7 +294,8 @@ class DockerClient
|
|||||||
"""
|
"""
|
||||||
command = submission.execution_environment.run_command % command_substitutions(filename)
|
command = submission.execution_environment.run_command % command_substitutions(filename)
|
||||||
create_workspace_files = proc { create_workspace_files(container, submission) }
|
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
|
end
|
||||||
|
|
||||||
def execute_test_command(submission, filename, &block)
|
def execute_test_command(submission, filename, &block)
|
||||||
|
Reference in New Issue
Block a user