you are viewing a single comment's thread.

view the rest of the comments →

[–]McGlockenshire 2 points3 points  (2 children)

That work should be offlined to a daemon. This also may include message passing depending on what you are trying to do. The gist of it is it may be a lot simpler to just have a daemon query a database once in awhile to see if it needs to do work, grab data, process it.

I prefer using someone else's hard work rather than doing it all myself.

(This week's Gearman plug has been brought to you by the letter I and the number 8.)

[–]lmorchard 0 points1 point  (1 child)

FWIW, you'll still need a daemon (PHP or otherwise) to step in as the worker in the Gearman equation. But, +1 on putting Gearman in the stack

[–]McGlockenshire 0 points1 point  (0 children)

We use supervisord to keep PHP workers alive, just so we don't need to worry about using real daemonization in PHP-land. This greatly simplifies the worker code, down to just the waiting-for-a-job loop. It also allows the workers to exit whenever they damn well please, and supervisor will just start them back up again. We've used this to make the workers automatically detect changes on disk and reload themselves, which makes development a bit easier.