cleanup and comments

This commit is contained in:
Brian Gough 2015-03-13 10:10:51 +00:00
parent 63ee4d1e7d
commit 9aaef729ad
2 changed files with 3 additions and 1 deletions

View file

@ -1,7 +1,7 @@
_ = require("underscore")
metrics = require("metrics-sharelatex")
logger = require("logger-sharelatex")
safe_exec = require('./SafeExec')
safe_exec = require("./SafeExec")
approvedFormats = ["png"]
fourtySeconds = 40 * 1000

View file

@ -9,6 +9,7 @@ child_process = require('child_process')
# group, then we can kill everything in that process group.
module.exports = (command, options, callback = (err, stdout, stderr) ->) ->
# options are {timeout: number-of-milliseconds, killSignal: signal-name}
[cmd, args...] = command.split(' ')
child = child_process.spawn cmd, args, {detached:true}
@ -22,6 +23,7 @@ module.exports = (command, options, callback = (err, stdout, stderr) ->) ->
if options.timeout?
killTimer = setTimeout () ->
try
# use negative process id to kill process group
process.kill -child.pid, options.killSignal || "SIGTERM"
catch error
logger.log process: child.pid, kill_error: error, "error killing process"