I am trying to create a node server that creates phantomjs processes to take screenshots. The Grab.js script works fine when executed, and I confirmed that it writes to stdout. The problem is that the node code that spawns the process just hangs. I confirmed that phantomjs is on the way. Does anyone know what could happen here or how can I fix this problem?
Here's the phantom code (grab.js) that displays the page and writes data to standard output:
var page = require('webpage').create(), system = require('system'), fs = require('fs'); var url = system.args[1] || 'google.com'; page.viewportSize = { width: 1024, height: 1200 }; page.open(url, function() { var b64 = page.renderBase64('png'); fs.write('/dev/stdout', b64, 'w'); phantom.exit(); });
And here is the node code that spawns the phantom progress and prints the result (hangs):
var http = require('http'), exec = require('child_process').exec, fs = require('fs'); exec('phantomjs grab.js google.com', function(error, stdout, stderr) { console.log(error, stdout, stderr); });
source share