Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running command line PHP through PHP-FPM

Currently I use PHP-FPM with NGINX for front end requests but also run some background processes through a long running PHP script using exec to run other scripts with the command line PHP. What I'm thinking though is that this would be more efficient if these were also run through PHP-FPM? Any ideas on how I would do this? Thanks.

like image 367
Rob Ryan Avatar asked Feb 03 '23 14:02

Rob Ryan


1 Answers

FPM is a tool to Manage FastCGI Processes. Just shuffle the letters. While it manages long-running PHP processes, it does so only under the mental umbrella of FastCGI.

Because you're creating a background work queue, you want something designed to manage a background work queue and running processes.

Gearman is an excellent choice for the work queue half. It's platform and language agnostic, and scan scale to the heavens and back. The PECL extension works well.

For keeping those long-running processes going, take a look at Supervisor.

The two make a great duo. Check out this blog post by PHP hacker Matthew Weier O'Phinney that documents some of his exploration with Gearman and Supervisor.

like image 159
Charles Avatar answered Feb 05 '23 04:02

Charles