|
Posted by "vieonet forums" on 10/21/94 11:20
Hi
I suggest to use cron table against php deamon, It'will we be more stable
and using less load.
regards
----- Original Message -----
From: "Richard Lynch" <ceo@l-i-e.com>
To: "kioto" <kioto@slacky.it>
Cc: "php-general" <php-general@lists.php.net>
Sent: Friday, June 24, 2005 5:18 AM
Subject: Re: [PHP] Socket server in PHP
> On Wed, June 22, 2005 11:52 pm, kioto said:
>> Hi all sorry for the ignorance :D.This is my first time with Socket and
>> i have
>> a question for you.I want create a script that run like daemon in
>> background
>> and listen incoming request.It's possible with socket open a stream to a
>> directory
>> and check any change on this directory ?
>> I want send notify about the state of directory through e-mail for
>> example:
>> when a user add new files or change any data.
>
> Sort of.
>
> I don't think you need anything as fancy as a Socket to do what you want.
>
> Just:
>
> http://php.net/filemtime on the directory to detect contents changed
> http://php.net/opendir and readdir to see what's in it
> http://php.net/clearstatcache to make PHP forget cached status of the
> above
> http://php.net/mail to send whatever emails you want
>
> An infinite loop with http://php.net/sleep to do this every few seconds.
>
> You'd maybe want to use http://php.net/pcntl to respond to system
> signals...
>
> You'd maybe want to store the current filemtime and "current" directory
> contents in a database or file so you'd be able to start/stop your process
> and still send every email for all changes, even the ones that happen
> while your program wasn't running.
>
> You could maybe launch it from the shell with "nohup" to NOT get killed,
> as I sort of understand it... Better read "man nohup" I think...
>
> Assuming it's RedHat or similar, you'd want to write a /etc/rc.d/init.d
> shell script to start/stop the PHP script.
>
> I dunno where you thought you'd want a Socket in all this. [shrug] Maybe
> I'm missing something...
>
> Or did you want to have it respond to requests for info about a specific
> directory?
>
> Perhaps what you REALLY want is another process that listens on a Socket
> to register the email has an "interest" in a specific directory. But you
> could do that in a web FORM just as easily. Then your program above would
> run through all the email/directory combinations and do its thing in a
> more granular manner.
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
[Back to original message]
|