wip, docker container is correctly created

This commit is contained in:
Henry Oswald
2018-02-26 14:29:30 +00:00
parent 8f6db5baff
commit b8c22f4d74
11 changed files with 495 additions and 485 deletions

View File

@@ -41,7 +41,7 @@ module.exports = CompileManager =
doCompile: (request, callback = (error, outputFiles) ->) ->
compileDir = getCompileDir(request.project_id, request.user_id)
console.log("doCompile",compileDir )
# console.log("doCompile", compileDir)
timer = new Metrics.Timer("write-to-disk")
logger.log project_id: request.project_id, user_id: request.user_id, "syncing resources to disk"
@@ -206,9 +206,9 @@ module.exports = CompileManager =
base_dir = Settings.path.synctexBaseDir(compileName)
file_path = base_dir + "/" + file_name
compileDir = getCompileDir(project_id, user_id)
synctex_path = Path.join(compileDir, "output.pdf")
synctex_path = "$COMPILE_DIR/output.pdf"
command = ["code", synctex_path, file_path, line, column]
CompileManager._runSynctex command, (error, stdout) ->
CompileManager._runSynctex project_id, user_id, command, (error, stdout) ->
return callback(error) if error?
if stdout.toLowerCase().indexOf("warning") == -1
logType = "log"
@@ -221,9 +221,9 @@ module.exports = CompileManager =
compileName = getCompileName(project_id, user_id)
base_dir = Settings.path.synctexBaseDir(compileName)
compileDir = getCompileDir(project_id, user_id)
synctex_path = Path.join(compileDir, "output.pdf")
logger.log({base_dir, project_id, synctex_path}, "base diiir")
CompileManager._runSynctex ["pdf", synctex_path, page, h, v], (error, stdout) ->
synctex_path = "$COMPILE_DIR/output.pdf"
command = ["pdf", synctex_path, page, h, v]
CompileManager._runSynctex project_id, user_id, command, (error, stdout) ->
return callback(error) if error?
logger.log project_id: project_id, user_id:user_id, page: page, h: h, v:v, stdout: stdout, "synctex pdf output"
callback null, CompileManager._parseSynctexFromPdfOutput(stdout, base_dir)
@@ -242,20 +242,22 @@ module.exports = CompileManager =
return callback(new Error("not a file")) if not stats?.isFile()
callback()
_runSynctex: (args, callback = (error, stdout) ->) ->
bin_path = Path.resolve(__dirname + "/../../bin/synctex")
_runSynctex: (project_id, user_id, command, callback = (error, stdout) ->) ->
seconds = 1000
outputFilePath = args[1]
CompileManager._checkFileExists outputFilePath, (error) ->
return callback(error) if error?
if Settings.clsi?.synctexCommandWrapper?
[bin_path, args] = Settings.clsi?.synctexCommandWrapper bin_path, args
logger.log({bin_path, args}, "synctex being run")
child_process.execFile bin_path, args, timeout: 10 * seconds, (error, stdout, stderr) ->
if error?
logger.err err:error, args:args, "error running synctex"
return callback(error)
callback(null, stdout)
#this is a hack, only works for docker runner
command.unshift("/opt/synctex")
directory = getCompileDir(project_id, user_id)
timeout = 10 * 1000
compileName = getCompileName(project_id, user_id)
console.log command, "_runSynctex"
CommandRunner.run compileName, command, directory, Settings.clsi.docker.image, timeout, {}, (error, stdout) ->
console.log("synctex run", stdout)
if error?
logger.err err:error, command:command, "error running synctex"
return callback(error)
callback(null, stdout)
_parseSynctexFromCodeOutput: (output) ->
results = []