Skip to content
Browse files

add timeout for conversion process

  • Loading branch information...
1 parent ab54f07 commit 45ac0ecba07e4578e99c3762662d6fc23fc4f95a @kcivey kcivey committed Nov 13, 2013
Showing with 5 additions and 2 deletions.
  1. +1 −0 config/defaults.json
  2. +4 −2 server.js
View
1 config/defaults.json
@@ -1,6 +1,7 @@
{
"basePath": "http://images.example.com",
"convertCommand": "/usr/bin/gm convert",
+ "convertTimeout": 10,
"port": 80,
"group": "www-data",
"user": "www-data",
View
6 server.js
@@ -11,6 +11,7 @@ var fs = require('fs'),
convertArguments = config.convertCommand.split(/\s+/),
convertCommand = convertArguments.shift(),
port = config.port,
+ convertTimeout = config.convertTimeout * 1000,
concurrency = config.concurrency || 1,
convertQueue;
@@ -139,9 +140,10 @@ function getTempFilename(options) {
}
function doConversion(task, callback) {
- var args = convertArguments.concat(task.rawFile, task.convertOptions, task.convertedFile);
+ var args = convertArguments.concat(task.rawFile, task.convertOptions, task.convertedFile),
+ execOptions = {timeout: convertTimeout};
console.log(convertCommand, args.join(' '));
- execFile(convertCommand, args, function (err, stdout, stderr) {
+ execFile(convertCommand, args, execOptions, function (err, stdout, stderr) {
if (err) {
console.log('convert error', err, stderr);
}

0 comments on commit 45ac0ec

Please sign in to comment.
Something went wrong with that request. Please try again.