4

We were using Gearman/PHP on Ubuntu to delegate our processes. On this (development) machine we were opening few terminal windows to start clients and workers respectively, but now on live machine we need to send our clients and workers into background so that we have our terminal free.

We found brianlmoon's GearmanManager. It looks exactly what we need, but the problem is that in its code we were only able to find the part of sending workers into background and nothing about doing the same with the clients.

Could someone give us more inputs how to send all client/server processes into background using GearmanManager?

luigi7up
  • 5,779
  • 2
  • 48
  • 58
  • Hmm, usually one doesn't need deamonized clients... I think you'll have to expand the code for that a little, create a clients_dir & alter scanning through that just a tiny bit. Shouldn't be that hard, basics of daemonizing are the same. – Wrikken Jul 20 '11 at 17:18
  • When you say send to the background, you mean something like `php myscript.php` and wanting the script to run in the background so you could have your bash prompt available again? If so, you can run `php myscript.php &` – sdot257 Jul 20 '11 at 17:21
  • To me, "daemonized" clients means asynchronous execution. Client requests something from a server, server responds that it will get to it, client goes in to a "status request" loop, server returns "Not yet" until it is done. And so on. –  Jul 20 '11 at 23:40

2 Answers2

2

GearmanManager is only concerned with workers. You don't "send" clients into the background. Clients can submit jobs as background jobs. Assuming that is what you want to do and you are using the PECL library, the GearmanClient->doBackground() method is what you want.

brianlmoon
  • 21
  • 2
1

PHP's Gearman PECL extension is what you should be invoking: http://php.net/gearman When you want to send the client processes into the background, you'd just use the GearmanClient->doBackground method. Then the client can either proceed with other tasks or exit. Otherwise when the client must wait for the task to complete, you want the GearmanClient->do method.

Eric Caron
  • 6,181
  • 1
  • 24
  • 26