Re: the cause of the cause, our speculation based on an occasional error message had to do with the process running out of the "special" unix file handles. The processes open and close lots of files (and yes, we are explicitly closing files) and it seems for no rhyme or reason after the processes run for a while the handles never seemed to really get freed and would stack up and house the daemons. We could never replicated in a lab, it would just happen from time to time and the errors were things we could not explicitly control from PHP. (Note that we found all this in the 4.x CLI and have not re-tested in the PHP 5.x CLI. Our solution works great so why change it? Plus, if there are any strange behaviors in the CLI they won't get exploited by dying and re-spawning.)
So, what I mean re: "eternal" is that we can give our base daemon class an optional "lifetime" count (e.g., the number of times the daemon should perform its core processing before suicide) and an optional "eternal" command. Since we have a common way to spawn our daemons this eternal command is usually just the current script name plus some specific command-line parameters. Once the daemon reaches its lifetime, it requests its death, optionally re-spawning itself if there is an eternal command given. This command can be kicked off via your method of choice, e.g. pcntl_exec, exec, etc. No real magic here, just a simple method to insure we can have clean process spaces. :-) -- AD -----Original Message----- From: Ron Korving [mailto:[EMAIL PROTECTED] Sent: Thursday, October 06, 2005 7:48 AM To: internals@lists.php.net Subject: Re: [PHP-DEV] CLI in PHP6 > FWIW A lot :) Thanks for the response. It's good to see it is possible. > However, a process running for a long time (yes, even on > Linux) will also just "die" for no reason. We have a few hints as to > what causes the deaths but don't know what causes the cause. To solve > the problem we created a daemon class that has a lifetime and can make > itself "eternal" if desired. The net effect is a stable daemon(s). Could you get into a little more detail? I don't quite understand what you mean by this daemon class that can make itself "eternal" and how this can turn the situation stable. Thanks, Ron ""J. Allen Dove"" <[EMAIL PROTECTED]> schreef in bericht news:[EMAIL PROTECTED] m... FWIW, we have been running a number of very high-volume PHP CLI daemons for the last 18-20 months with great success. That is not to say it wasn't a challenge to get them as "stable" as a C++ daemon but we have. PHP 4.x CLI seemed to have a mem leak somewhere, PHP 5.x seems to have resolved that. However, a process running for a long time (yes, even on Linux) will also just "die" for no reason. We have a few hints as to what causes the deaths but don't know what causes the cause. To solve the problem we created a daemon class that has a lifetime and can make itself "eternal" if desired. The net effect is a stable daemon(s). We currently process 65-70MM transactions a day with our PHP-based daemons. We chose to try using PHP to share business logic and it paid off. -- Allen -----Original Message----- From: Ron Korving [mailto:[EMAIL PROTECTED] Sent: Thursday, October 06, 2005 2:49 AM To: internals@lists.php.net Subject: [PHP-DEV] CLI in PHP6 Hi, There was once (can't remember when exactly, so it must be a long time ago) here on PHP CLI scripts in which it came forward that one should not rely on such a script to run forever. And it's true; the scripts sometimes magically and suddenly die. Now I have no clue where this instability (for lack of a better word) comes from, but could it be possible for this to be resolved for PHP6 so that PHP becomes an extremely viable solution for CLI daemon scripts? Thanks, Ron Korving -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php