0
votes

again, im stucking in Gearman. I was implementing the ulabox gearman Bundle which works nicely. But there are two things which I dont unterstand yet.

  • How do I start a Worker?? Im the documentation, I should first execute a worker and the start the code.

https://github.com/ulabox/GearmanBundle/blob/master/README.md

Open the first console and run:

$ php app/console gearman:worker:execute --worker=AcmeDemoBundle:AcmeWorker

Now open another console and run:

$ php app/console gearman:client:execute --client=UlaboxGearmanBundle:GearmanClient:hello_world --worker=AcmeDemoBundle:AcmeWorker --params="{\"foo\": \"bar\" }"

So, if I dont start the worker manually, the job would be done by itsself. If I start the worker, everysthin is fine. But at least, it is a bit strange to start in manually, even if there is set an iteration of x so that the worker will kill itsself after that amount of job.

So please, can anyone help me out of this :((((

Heeeeeelp :) lol

thanks in advance an kind regards

Phil

1

1 Answers

0
votes

Yes to run some task in background not only Gearman need to be run but also workers. So you have run "gearman" that wait for some command (e.x. email send). Additionally you have waiting workers.

When gearman view new command he look for first free worker and pass this command to it. Next worker process execution for command and after finish return to Gearman server that it finished and ready to process new command.

More worker you have faster commands in queue processed.

You can use "supervisor" for automatic maintenance workers running. Bellow you can find few links with more information:

http://www.daredevel.com/php-jobs-with-gearman-and-supervisor/ http://www.masnun.com/2011/11/02/gearman-php-and-supervisor-processing-background-jobs-with-sanity.html Running Gearman Workers in the Background