Show correct timeout message on timeout. Do not show a message on valid exit.

This commit is contained in:
Ralf Teusner
2015-10-21 17:18:28 +02:00
parent 889d7562f9
commit 30d0270744
3 changed files with 17 additions and 10 deletions

View File

@@ -30,7 +30,7 @@ $(function() {
numMessages = 0,
turtlecanvas = $('#turtlecanvas'),
prompt = $('#prompt'),
commands = ['input', 'write', 'turtle', 'turtlebatch', 'exit', 'status'],
commands = ['input', 'write', 'turtle', 'turtlebatch', 'exit', 'timeout', 'status'],
streams = ['stdin', 'stdout', 'stderr'];
var ENTER_KEY_CODE = 13;
@@ -1004,7 +1004,7 @@ $(function() {
};
var showTimeoutMessage = function() {
$.flash.danger({
$.flash.info({
icon: ['fa', 'fa-clock-o'],
text: $('#editor').data('message-timeout')
});
@@ -1059,14 +1059,6 @@ $(function() {
running = false;
toggleButtonStates();
hidePrompt();
flashKillMessage();
}
var flashKillMessage = function() {
$.flash.info({
icon: ['fa', 'fa-clock-o'],
text: "Your program was stopped." // todo get data attribute
});
}
// todo set this from websocket command, required to e.g. stop container
@@ -1176,6 +1168,10 @@ $(function() {
case 'exit':
killWebsocketAndContainer();
break;
case 'timeout':
// just show the timeout message here. Another exit command is sent by the rails backend when the socket to the docker container closes.
showTimeoutMessage();
break;
case 'status':
showStatus(msg)
break;

View File

@@ -90,6 +90,12 @@ class SubmissionsController < ApplicationController
hijack do |tubesock|
Thread.new { EventMachine.run } unless EventMachine.reactor_running? && EventMachine.reactor_thread.alive?
# socket is the socket into the container, tubesock is the socket to the client
# give the docker_client the tubesock object, so that it can send messages (timeout)
@docker_client.tubesock = tubesock
result = @docker_client.execute_run_command(@submission, params[:filename])
tubesock.send_data JSON.dump({'cmd' => 'status', 'status' => result[:status]})