문제

I have the Gearman Job server where I am planning on creating the workers and do all the heavy lifting. The Gearman Job Server is called from an application server by a PHP script (already installed the gearman client on it).

Tested if the Gearman is working on the Job Server and received the following response:

ubuntu@ip XXXXXXX:~$ ps -e|grep gearman
24255 ?        00:00:00 gearmand    

And I also tested on my application server if the gearman is working by doing :

<?php
print gearman_version() . "\n";
?>

Which printed the gearman version so its working.

Now I have a client which makes the call to Job Server. But I am having difficulty finding where to put the PHP workers, link them to Gearman so it know which worker to execute when client makes a call.

Any help is much appreciated. Thanks

도움이 되었습니까?

해결책

Gearman Workers need to be started separately, so it doesn't really matter where you put them. After you have written the worker code, just start the script from the terminal using

php /path/to/worker/gearman-worker.php

As the script starts, it will register itself with the given server and pick-up any jobs that might be available.

You can read about the Gearman worker here, but notice the important part is the server registration

$worker -> addServer();

Here, calling the function without any arguments will register the worker to a Gearman server running on localhost, but you can make it register to any server on any port by setting these arguments (as specified in the link above).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top