Last active
March 24, 2016 01:58
-
-
Save NoiseEee/432d3e21de38436385f5 to your computer and use it in GitHub Desktop.
What is the difference?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The Gearman Worker script | |
*/ | |
$worker= new GearmanWorker(); | |
$worker->addServer(); | |
$worker->addFunction("LayoutbooksAssembler", "sendToCasper"); | |
while ($worker->work()); | |
function sendToCasper($job) { | |
echo "whoami you ask? "; | |
$processUser = posix_getpwuid(posix_geteuid()); | |
print $processUser['name']; | |
echo "!\r\n\r\n"; | |
$jobParams = (array) json_decode($job->workload()); | |
exec("phantomjs --version",$output); | |
var_dump($output); //got the phantomjs version (2.1) | |
//everything thus far is rendered to screen or logged just fine when worker is initiated via CLI *or* supervisord | |
//but if started from supervisord, the casperjs process below hangs (phantomjs takes 99% CPU until killed) and nothing in a casper script runs | |
exec("casperjs --version",$moreOutput) | |
var_dump($moreOutput); //will never get here if gearman worker is started from anything but CLI | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/bin/php /var/www/xmweb/gearman_client_tests/casperTest.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[program:casperWorker] | |
command=/usr/bin/php /var/www/xmweb/gearman_client_tests/casperTest.php | |
process_name=casperWorker | |
numprocs=1 | |
user=vagrant | |
environment=GEARMAN_USER="vagrant" | |
stopsignal=KILL | |
autostart=true | |
autorestart=true | |
stdout_logfile=/home/vagrant/gearmanLogs/casper.log | |
stderr_logfile=/home/vagrant/gearmanLogs/casper_errors.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
phantomJS version: 2.1
casperJS version: 1.1-beta5
When initiating my worker from the CLI, all is great... when I try to initiate it via supervisord, phantomjs/casperjs hang indefinitely, use 99.7% cpu and the casper script does not run... though all the other stuff before the command does run. The worker sees itself as "vagrant" when started via CLI or supervisord; even a simple 'casperjs --version' will cause casperjs to hang when run from supervisord, unlike 'phantomjs --version' (both will run fine when started via CLI)
WHAT IS HAPPENING!!! Any tips appreciated, ultimately I need these worker scripts to start via supervisord!