FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » php daemon
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: php daemon [message #179610 is a reply to message #179589] Tue, 13 November 2012 07:57 Go to previous messageGo to previous message
Goran is currently offline  Goran
Messages: 38
Registered: January 2011
Karma:
Member
On 11.11.2012 18:18, sl@exabyte wrote:
> Anybody has experience of running php program as daemon ?
>
> Would explicitly allocating and de-allocating all variables/memories be
> effective for managing php daemon ?

PHP daemons are common pattern in some situations. E.g. how would you
implement AMQP listener without daemon?

But, due to the stateless nature of web, PHP is not made for daemonizing
:) Fortunately, there is solution, just keep in mind the following:

1. don't overuse this possibility - avoid it if you can
2. don't depend on PHP's memory management - shutdown your script
automatically from time to time just to be safe of memory leakage
3. auto start it immediately after shutdown - use supervisord

Basically, do this:

<?php

define('MAX_ITERATIONS', 10);

for ($iteration = 0; $iteration < MAX_ITERATIONS; $iteration++)
{
// Do something nasty
// ...

sleep(10);
}

?>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Benefits of the 3-Tier Architecture
Next Topic: Bad database design can cause unnecessary coding
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 11:51:59 GMT 2024

Total time taken to generate the page: 0.04007 seconds