Skip to content

Instantly share code, notes, and snippets.

@NoiseEee
Last active March 24, 2016 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NoiseEee/432d3e21de38436385f5 to your computer and use it in GitHub Desktop.
Save NoiseEee/432d3e21de38436385f5 to your computer and use it in GitHub Desktop.
What is the difference?
<?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
}
/usr/bin/php /var/www/xmweb/gearman_client_tests/casperTest.php
[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
@NoiseEee
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment