I'm using the phantomjs gem: https://github.com/colszowka/phantomjs-gem
When the script is launched from the controller:
Phantomjs.run('./public/javascripts/test.js')
The rails server hangs while the script is running, waiting for it to finish.
The phantomjs script, 'test.js' looks like this:
var page = require('webpage').create();
page.viewportSize = { width: 1920, height: 1080 };
page.open('http://localhost:3000', function () {
window.setTimeout(function () {
page.render('./public/test.png');
phantom.exit();
}, 3000);
});
What I'm assuming the problem is, is that rails is waiting for the script to finish while phantomjs is trying to access the rails server, but since the server is busy, they both hold each other up.
Any solutions?
EDIT to address @Artjom B.:
1) Yes I'm using PhantomJS 2.0 on ubuntu 14.04 LTS, I'll try an earlier version.
2) Not sure what you're asking here, I can't access the log from phantomjs this way so anything logged to console is unseen by me. If you know a way around this let me know. Can't seem to run -debugger on the phantomjs call from ruby.
3) Yes the script works great from the command line, no issues at all.
4) Not following you here, either. The Phantomjs.run command is being fired from my controller under a test action. This command runs fine if opening a page other than my local server.