From 559e2f5d98fbec08d46e4db581c1e435e7869ae3 Mon Sep 17 00:00:00 2001 From: "honza.pofider@seznam.cz" Date: Sun, 31 May 2015 09:34:35 +0200 Subject: [PATCH] refactor new strategies --- README.md | 5 ++++- index.js | 2 +- lib/manager-processes.js | 2 +- lib/manager-servers.js | 4 ++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fd8c81c..3104e6b 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,10 @@ var scriptManager = require("script-manager")({ host: '127.0.0.1', /* set a specific port range for script execution server */ portLeftBoundary: 1000, - portRightBoundary: 2000 + portRightBoundary: 2000, + /* switch to use dedicated process for script evalution, this can help with + some issues caused by corporate proxies */ + strategy: "http-server | dedicated-process" }); ``` diff --git a/index.js b/index.js index 431992e..4e61a33 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,7 @@ module.exports = function(options) { options.timeout = options.timeout || 10000; options.strategy = options.strategy || "http-servers"; - if (options.strategy === "http-servers") { + if (options.strategy === "http-server") { return new (require("./lib/manager-servers.js"))(options); } diff --git a/lib/manager-processes.js b/lib/manager-processes.js index ba0c9f5..aaa1fee 100644 --- a/lib/manager-processes.js +++ b/lib/manager-processes.js @@ -71,7 +71,7 @@ ScriptsManager.prototype.execute = function (inputs, options, cb) { worker.kill(); - cb(new Error("Timeout error during rendering")); + cb(new Error("Timeout error during executing script")); }, options.timeout || this.options.timeout); }; diff --git a/lib/manager-servers.js b/lib/manager-servers.js index 2ce4f94..9b3e15a 100644 --- a/lib/manager-servers.js +++ b/lib/manager-servers.js @@ -182,6 +182,10 @@ ScriptsManager.prototype.execute = function (inputs, options, cb) { return cb(err); } + if (!body) { + return cb(new Error("Something went wrong in communication with internal scripting server. You may try to change scripting strategy from `http-server` to `dedicated-process`.")) + } + if (body.error) { var e = new Error(); e.message = body.error.message;