diff --git a/slapos/runner/static/js/scripts/shell.js b/slapos/runner/static/js/scripts/shell.js index ec2d454a25ad5f6886724efcdc229b532f138893..efcc4f641b314189f437ff858d9a83522f394b29 100644 --- a/slapos/runner/static/js/scripts/shell.js +++ b/slapos/runner/static/js/scripts/shell.js @@ -38,18 +38,24 @@ $(document).ready(function () { var data = { command: command }; var old_shell_btn_background = $(".shell_btn").css("background"); $(".shell_btn").css("background", "url(/static/css/images/loading-min.gif) center right no-repeat") - $.post("/runCommand", data, function (data) { - var data = "<p><span class=\"runned-command\">" + data.path + " >>> " + command + "</span></p><br/><pre>" + data.data + "</pre><br/>"; - $("#shell-result").append(data); - $("#shell-input").val(""); - $("#shell-result").scrollTop($("#shell-result")[0].scrollHeight); - updateHistory(); + $.ajax({ + type: "POST", + url: $SCRIPT_ROOT + "/runCommand", + data: data, + timeout: 600000 + }) + .done( function (data) { + var data = "<p><span class=\"runned-command\">" + data.path + " >>> " + command + "</span></p><br/><pre>" + data.data + "</pre><br/>"; + $("#shell-result").append(data); + $("#shell-input").val(""); + $("#shell-result").scrollTop($("#shell-result")[0].scrollHeight); + updateHistory(); }) .fail( function(xhr, status, error) { - $("#error").Popup("Error while sending command. Server answered with :\n" + xhr.statusCode().status + " : " + error, {type: 'error', duration: 3000}) + $("#error").Popup("Error while sending command. Server answered with :\n" + xhr.statusCode().status + " : " + error, {type: 'error', duration: 3000}) }) .always( function() { - $(".shell_btn").css("background", old_shell_btn_background); + $(".shell_btn").css("background", old_shell_btn_background); }); } }); diff --git a/slapos/runner/views.py b/slapos/runner/views.py index 0d986b9ba228bd039d72231fe187459f60fe444c..5ef281cb4b99ecc959d49a890af7cc31819d5dc9 100755 --- a/slapos/runner/views.py +++ b/slapos/runner/views.py @@ -730,6 +730,7 @@ def runCommand(): return jsonify(path=cwd, data="Changed directory, now in : "+cwd) try: setMiniShellHistory(app.config, command) + command = "timeout 600 " + command return jsonify(path=cwd, data=subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True, cwd=cwd)) except subprocess.CalledProcessError as e: error = "Error : process exited with exit code " + str(e.returncode) + \