0

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

TheTom
  • 934
  • 2
  • 14
  • 40

1 Answers1

0

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

Community
  • 1
  • 1
  • Isn't that exactly what the gearman-Manager is doing? I haven't found a Bundle which includes the Manager in symfony. THis is strange because the Manager is well done an can handle everything on it's own. Is this the normal way to get supervisor handle the workers or is there another possibility? – TheTom Jul 08 '14 at 07:13
  • What you mean by gearman-manager? Supervisor used to run worker, nothing else. – Oleksandr Otchenashev Jul 08 '14 at 09:10
  • Oh there is some important info missing from my side. I'm using symfony2. There, the ulaboxBundle is installed. So the worker is implemented in a Bundle which i created for testing. Should I use the usr/bin/php ? Because the worker is not able to run as a php as I call him by console [code]php app/console gearman:worker:execute --worker=PrGwBundle:PrWorker[/code] – TheTom Jul 08 '14 at 09:45
  • This is not a problem. I also work with SF2 and MmoreramerinoGearmanBundle. In supervisor I just put php command to run. e.x. command=/usr/bin/php /var/www/project/app/console gearman:worker:execute NameBundleWorkersNameWorker --no-interaction --env live – Oleksandr Otchenashev Jul 08 '14 at 09:53
  • ah ok. tahts cool. I tryed too but i get an "INFO gave up: gearman entered FATAL state, too many start retries too quickly" while I'm running supervisord -n :( – TheTom Jul 08 '14 at 09:59
  • this mean Gearman worker not start correctly and return FATAL on start. So first verify that manual run command run correctly. If it so move it to supervisor. During development better run command by hand. On production/staging server use supervisor to guarantee that worker work – Oleksandr Otchenashev Jul 08 '14 at 10:03