fix CompileManager and LocalCommandRunner

This commit is contained in:
Tailing Yuan 2019-10-04 22:34:45 +08:00
parent e70c502028
commit 68e842b12a
2 changed files with 8 additions and 4 deletions

View file

@ -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)

View file

@ -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