Skip to content

Commit

Permalink
refactor new strategies
Browse files Browse the repository at this point in the history
  • Loading branch information
pofider committed May 31, 2015
1 parent d5f648c commit 559e2f5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
});
```

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/manager-processes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down
4 changes: 4 additions & 0 deletions lib/manager-servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 559e2f5

Please sign in to comment.