mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-31 08:04:13 +00:00
clean up the stdout/stderr recording
This commit is contained in:
parent
3db513cfc9
commit
63770bf390
2 changed files with 30 additions and 7 deletions
|
@ -217,11 +217,6 @@ module.exports = CompileManager = {
|
|||
error = new Error('compilation')
|
||||
error.validate = 'fail'
|
||||
}
|
||||
// make top-level output accesible to user, write in background for simplicity
|
||||
if (output != null) {
|
||||
fs.writeFile(Path.join(compileDir, "output.stdout"), output.stdout, () => { })
|
||||
fs.writeFile(Path.join(compileDir, "output.stderr"), output.stderr, () => { })
|
||||
}
|
||||
// compile was killed by user, was a validation, or a compile which failed validation
|
||||
if (
|
||||
(error != null ? error.terminated : undefined) ||
|
||||
|
|
|
@ -19,6 +19,7 @@ const Settings = require('settings-sharelatex')
|
|||
const logger = require('logger-sharelatex')
|
||||
const Metrics = require('./Metrics')
|
||||
const CommandRunner = require('./CommandRunner')
|
||||
const fs = require('fs')
|
||||
|
||||
const ProcessTable = {} // table of currently running jobs (pids or docker container names)
|
||||
|
||||
|
@ -127,9 +128,36 @@ module.exports = LatexRunner = {
|
|||
: undefined,
|
||||
x5 => x5[1]
|
||||
) || 0
|
||||
return callback(error, output, stats, timings)
|
||||
// record output files
|
||||
LatexRunner.writeLogOutput(project_id, directory, output, () => {
|
||||
return callback(error, output, stats, timings)
|
||||
})
|
||||
}))
|
||||
},
|
||||
|
||||
writeLogOutput(project_id, directory, output, callback) {
|
||||
if (!output) {
|
||||
return callback()
|
||||
}
|
||||
// internal method for writing non-empty log files
|
||||
function _writeFile(file, content, cb) {
|
||||
if (content && content.length > 0) {
|
||||
fs.writeFile(file, content, (err) => {
|
||||
if (err) {
|
||||
logger.error({ project_id, file }, "error writing log file") // don't fail on error
|
||||
}
|
||||
cb()
|
||||
})
|
||||
} else {
|
||||
cb()
|
||||
}
|
||||
))
|
||||
}
|
||||
// write stdout and stderr, ignoring errors
|
||||
_writeFile(Path.join(directory, "output.stdout"), output.stdout, () => {
|
||||
_writeFile(Path.join(directory, "output.stderr"), output.stderr, () => {
|
||||
callback()
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
killLatex(project_id, callback) {
|
||||
|
|
Loading…
Reference in a new issue