I am having a very strange issue with a shell_exec
.
What I am trying to do is to call a PhantomJS and pass 4 arguments to it (user Session ID, URL, file save name and element that I need to take) using shell_exec in order to make a screenshot of a certain element on a page.
So, my command looks like this:
/usr/local/bin/phantomjs --ignore-ssl-errors=true /Users/Igor/Sites/something/public_html/lib/phantomjs/script.js https://testsite.com/dashboard/\?dashboard_view=somedash /Users/Igor/Sites/something/uploads/screenshots/j78O3LstYumBnUi fef81e774e845d44044c167c6847f4d1 chart1 2>&1
This is what I execute using shell_exec:
$command = ' --ignore-ssl-errors=true ' . $this->script . ' ' . escapeshellarg($this->uri) . ' ' . escapeshellarg($path) . ' ' . $this->session . ' ' . $this->element;
$output = shell_exec("$this->phantomjs $command 2>&1 1> /dev/null");
After I call shell_exec
I clearly see that command has been executed using "ps uax | grep phantom"
but it stays there forever, causing a instant death of PHP-FPM (v5.4.45) and Apache2 on a server. I need to add that I am executing this command asynchronously via AJAX call.
I've tried different approaches - using something else instead of shell_exec
, making a Bash script that will accept arguments, PhantomJS Runner.... nothing works.
If I execute this command in a console - it works without issues.
I am out of ideas really - not sure how to proceed any further so any help would be appreciated.