Skip to content

Commit

Permalink
Added: listen option for interface binding
Browse files Browse the repository at this point in the history
  • Loading branch information
psi-4ward committed Jun 2, 2016
1 parent f2d7e15 commit 87297ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ var render = phantom({
expects : 'something', // No default. Do not render until window.renderable is set to 'something'
retries : 1, // How many times to try a render before giving up. Defaults to 1.
phantomFlags: ['--ignore-ssl-errors=true'] // Defaults to []. Command line flags passed to PhantomJS
maxRenders : 500, // How many renders can a phantom process make before being restarted. Defaults to 500
maxRenders : 500, // How many renders can a phantom process make before being restarted. Defaults to 500
listener : '0.0.0.0', // Specify the interface to bind (ie 127.0.0.1)

injectJs : ['./includes/my-polyfill.js'] // Array of paths to polyfill components or external scripts that will be injected when the page is initialized
});
Expand Down
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var noop = function() {};

var TMP = path.join(fs.existsSync('/tmp') ? '/tmp' : os.tmpDir(), 'phantom-render-stream');

var serve = function() {
var serve = function(opts) {
var cache = LRU(200);
var server = http.createServer(function(request, response) {
request.connection.unref();
Expand All @@ -45,7 +45,7 @@ var serve = function() {
});

var listen = thunky(function(cb) {
server.listen(0, function() {
server.listen(0, opts.listen, function() {
server.unref();

var port = server.address().port;
Expand Down Expand Up @@ -238,13 +238,14 @@ var create = function(opts) {
retries : 1,
tmp : TMP,
format : 'png',
quality : 100
quality : 100,
listen : '0.0.0.0'
};

opts = xtend(defaultOpts,opts);

var worker = pool(opts);
var server = serve();
var server = serve(opts);
var queued = {};

worker.on('data', function(data) {
Expand Down

0 comments on commit 87297ad

Please sign in to comment.