From 68e842b12a5ff520d204331fe5c45e1fecc9fe0c Mon Sep 17 00:00:00 2001 From: Tailing Yuan Date: Fri, 4 Oct 2019 22:34:45 +0800 Subject: [PATCH] fix CompileManager and LocalCommandRunner --- services/clsi/app/coffee/CompileManager.coffee | 2 +- services/clsi/app/coffee/LocalCommandRunner.coffee | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/services/clsi/app/coffee/CompileManager.coffee b/services/clsi/app/coffee/CompileManager.coffee index ad924e2b1e..65b78aaff8 100644 --- a/services/clsi/app/coffee/CompileManager.coffee +++ b/services/clsi/app/coffee/CompileManager.coffee @@ -250,7 +250,7 @@ module.exports = CompileManager = directory = getCompileDir(project_id, user_id) timeout = 60 * 1000 # increased to allow for large projects compileName = getCompileName(project_id, user_id) - CommandRunner.run compileName, command, directory, Settings.clsi.docker.image, timeout, {}, (error, output) -> + CommandRunner.run compileName, command, directory, Settings.clsi?.docker.image, timeout, {}, (error, output) -> if error? logger.err err:error, command:command, project_id:project_id, user_id:user_id, "error running synctex" return callback(error) diff --git a/services/clsi/app/coffee/LocalCommandRunner.coffee b/services/clsi/app/coffee/LocalCommandRunner.coffee index f47af00177..c5ef3c692c 100644 --- a/services/clsi/app/coffee/LocalCommandRunner.coffee +++ b/services/clsi/app/coffee/LocalCommandRunner.coffee @@ -5,7 +5,7 @@ logger.info "using standard command runner" module.exports = CommandRunner = run: (project_id, command, directory, image, timeout, environment, callback = (error) ->) -> - command = (arg.replace('$COMPILE_DIR', directory) for arg in command) + command = (arg.toString().replace('$COMPILE_DIR', directory) for arg in command) logger.log project_id: project_id, command: command, directory: directory, "running command" logger.warn "timeouts and sandboxing are not enabled with CommandRunner" @@ -15,7 +15,11 @@ module.exports = CommandRunner = env[key] = value for key, value of environment # run command as detached process so it has its own process group (which can be killed if needed) - proc = spawn command[0], command.slice(1), stdio: "inherit", cwd: directory, detached: true, env: env + proc = spawn command[0], command.slice(1), cwd: directory, env: env + + stdout = "" + proc.stdout.on "data", (data)-> + stdout += data proc.on "error", (err)-> logger.err err:err, project_id:project_id, command: command, directory: directory, "error running command" @@ -32,7 +36,7 @@ module.exports = CommandRunner = err.code = code return callback(err) else - callback() + callback(null, {"stdout": stdout}) return proc.pid # return process id to allow job to be killed if necessary