Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow bridge host and port to be specified via options #141

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
var webpage = require('webpage');
var webserver = require('webserver').create();
var system = require('system');
var host = system.args[1];
var port = system.args[2];

var pages = {};
var page_id = 1;
Expand Down Expand Up @@ -91,7 +93,7 @@ function include_js (res, page, args) {
}));
}

webserver.listen('127.0.0.1:0', function (req, res) {
webserver.listen(host + ':' + port, function (req, res) {
// Update watchdog timer on every request
watchdog_clear();

Expand Down
4 changes: 4 additions & 0 deletions node-phantom-simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ exports.create = function (options, callback) {
if (typeof options.parameters === 'undefined') { options.parameters = {}; }

function spawnPhantom (callback) {
var bridgeDefaults = { host: '127.0.0.1', port: '0' };
var args = [];

if (Array.isArray(options.parameters)) {
Expand All @@ -136,6 +137,9 @@ exports.create = function (options, callback) {

args = args.concat([ path.join(__dirname, 'bridge.js') ]);

var bridgeOptions = Object.assign(bridgeDefaults, options.bridge || {});
args = args.concat([ bridgeOptions.host, bridgeOptions.port ]);

var phantom = spawn(options.path, args);

phantom.once('error', function (err) {
Expand Down