News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Simas Toleikis' Blog:
Writing a PHP daemon application
January 19, 2011 @ 11:51:34

Simas Toleikis has a new post today looking at a method he's found for creating a simple daemon application in PHP. He gives you the basic outline of how it works (with a bit of code included) but not a specific example.

There is a special group of applications that require a different PHP script execution model. [...] All of [these special] applications need to be run in the background as daemons - something that PHP was never designed/supposed to be good at. The plain C language is a weapon of choice when it comes to writing a daemon implementation, but then again, if the application in question does not depend on high performance and concurrency - PHP can do the job quite well.

He talks about using the command line interface to run the scripts, creating the while loop to keep execution going and creating the non-blocking socket so that the script can accept new client connections. He also mentions using upstart to run the script in the background and the proctitle PECL extension to give the process a custom name in the process list. He also touches on log files and forking/parallel processing.

0 comments voice your opinion now!
daemon application tutorial proctitle cli upstart


Mark Karpeles' Blog:
proctitle a new step for pinetd
January 22, 2009 @ 11:12:17

If you've ever worked with forking processes in PHP, you know things can get a little difficult when you have more than one process going at a time. Identification can become a hassle, especially if you need to kill one off because of performance issues. If you've found yourself in this spot before, you might want to check out this update Mark Karpeles has made to his pinetd project to allow for naming of those forked processes.

Ever wanted to give meaningful names to your processes when you pcntl_fork() with PHP ? proctitle is the extension you're looking for! Adapted from bug report #29479 and code initially wrote by Midom for Wikipedia, the proctitle extension allows for a process to change its own displayed title in the system's process list.

The extension (seen in action here) is an interface for making different sorts of daemons, including the ability to give them names. You can check out the project here.

0 comments voice your opinion now!
pinetd proctitle extension daemon tcp udp name process fork



Community Events





Don't see your event here?
Let us know!


threedevsandamaybe interview series community zendserver deployment language bugfix tips introduction symfony framework laravel podcast release voicesoftheelephpant code api list conference

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework