Skip to content

Instantly share code, notes, and snippets.

@marinsagovac
Last active January 1, 2018 19:02
Show Gist options
  • Select an option

  • Save marinsagovac/457fdfeb3d26c364119784133049a492 to your computer and use it in GitHub Desktop.

Select an option

Save marinsagovac/457fdfeb3d26c364119784133049a492 to your computer and use it in GitHub Desktop.
Gearman PHP 7
=== Install Gearman ===
sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update
sudo apt-get -y install php7.0 php7.0-fpm php-gearman
sudo touch /var/log/gearmand.log
sudo chmod 0666 /var/log/gearmand.log
gearmand -d
sudo apt-get install gearman-tools
=== Check gearman ===
php --info | grep gearman
=== Worker ("w" = worker, "-l forked process") ===
gearman -w -f wc -- wc -l
=== Client (foreground service "-f", background: "-b") alias "wc -l < /etc/passwd" ===
gearman -f wc < /etc/passwd
=== PHP Extension ===
php -m | grep "gearman"
# extension="gearman.so"
# If Exists, test with PHP:
# <?php print gearman_version();
=== PHP manual ===
http://php.net/manual/en/book.gearman.php
=== Create PHP worker ===
wget https://raw.githubusercontent.com/hjr3/pecl-gearman/master/examples/reverse_worker.php
=== Create PHP client and fix "doNormal" code
wget https://raw.githubusercontent.com/hjr3/pecl-gearman/master/examples/reverse_client.php
=== Status worker ====
gearadmin --status
gearmadmin --workers
=== Issues with Gearman ===
https://github.com/mmoreram/GearmanBundle/issues/45
Fix:
$result= $gmclient->doNormal("reverse", "Hello!");
to:
$result= $gmclient->do("reverse", "Hello!");
=== Another samples ===
http://gearman.org/examples/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment