diff --git a/services/filestore/app/coffee/FileConverter.coffee b/services/filestore/app/coffee/FileConverter.coffee index 337f721ffa..c53828d454 100644 --- a/services/filestore/app/coffee/FileConverter.coffee +++ b/services/filestore/app/coffee/FileConverter.coffee @@ -6,6 +6,10 @@ approvedFormats = ["png"] twentySeconds = 20 * 1000 +childProcessOpts = + killSignal: "SIGKILL" + timeout: twentySeconds + module.exports = convert: (sourcePath, requestedFormat, callback)-> @@ -17,9 +21,7 @@ module.exports = err = new Error("invalid format requested") return callback err args = "nice convert -flatten -density 300 #{sourcePath} #{destPath}" - opts = - timeout: twentySeconds - exec args, opts, (err, stdout, stderr)-> + exec args, childProcessOpts, (err, stdout, stderr)-> timer.done() if err? logger.err err:err, stderr:stderr, sourcePath:sourcePath, requestedFormat:requestedFormat, destPath:destPath, "something went wrong converting file" @@ -37,9 +39,7 @@ module.exports = width: 424 height: 300 args = "nice convert -flatten -background white -resize 260x -density 300 #{sourcePath} #{destPath}" - opts = - timeout: twentySeconds - exec args, opts,(err, stdout, stderr)-> + exec args, childProcessOpts, (err, stdout, stderr)-> if err? logger.err err:err, stderr:stderr, sourcePath:sourcePath, "something went wrong converting file to preview" else @@ -56,9 +56,7 @@ module.exports = width: 600 height: 849 args = "nice convert -flatten -background white -resize 548x -density 300 #{sourcePath} #{destPath}" - opts = - timeout: twentySeconds - exec args, opts,(err, stdout, stderr)-> + exec args, childProcessOpts, (err, stdout, stderr)-> if err? logger.err err:err, stderr:stderr, sourcePath:sourcePath, destPath:destPath, "something went wrong converting file to preview" else diff --git a/services/filestore/app/coffee/ImageOptimiser.coffee b/services/filestore/app/coffee/ImageOptimiser.coffee index 7aece25464..dbddaa3205 100644 --- a/services/filestore/app/coffee/ImageOptimiser.coffee +++ b/services/filestore/app/coffee/ImageOptimiser.coffee @@ -10,11 +10,12 @@ module.exports = args = "optipng #{localPath}" opts = timeout: 20 * 1000 + killSignal: "SIGKILL" exec args, opts,(err, stdout, stderr)-> if err? logger.err err:err, stderr:stderr, localPath:localPath, "something went wrong converting compressPng" else logger.log localPath:localPath, "finished compressPng file" - callback(err) + callback(err)