------------------------------------------------
On Wed, 24 Sep 2003 13:17:54 -0500, "NIPP, SCOTT V (SBCSI)" <[EMAIL PROTECTED]> wrote:
> OK. Thanks.
>
> I was wondering if this is something that I could simply write a
> while loop that never meets the exit condition, and then simply check the
> directory in question for files. If files exist, the "daemon" kicks off the
> appropriate processing script and then deletes the file afterwards. If
> there are no files, then the "daemon" simply sleeps for 30 seconds before
> looking again. This seems like a very simple way of attacking the issue.
> Any ideas fore or against?
>
The issues you will run into with the while(1) { do some stuff } approach will have to
do with concurrency and blocking mostly. Assuming you are forking the "do some stuff"
and not needing much control over it with respect to return values, logging, etc. then
that method will work reasonably well. Once you add polling of a directory for new
files (especially a remote directory) you may run into more issues, but these mainly
get back to the "am I still able to poll? if not then what?" or "am I already polling
and just taking a really long time in which case I shouldn't poll again, etc." types
of things. Since I have it on the brain, have already written a relatively high-end
application using it, and have found it fascinating to work with I will throw POE into
the discussion. It has a rather steep learning curve, but once you "get it", it makes
tackling this kind of problem trivial.
http://poe.perl.org for more.
As to specifics related to "becoming a daemon" as opposed to "I want a program that is
always running" you should check out the Proc::Daemon::Init module (there was another
posted recently but I haven't used it specifically).
http://danconia.org
>
>
> -----Original Message-----
> From: James Edward Gray II [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, September 24, 2003 1:04 PM
> To: NIPP, SCOTT V (SBCSI)
> Cc: [EMAIL PROTECTED]
> Subject: Re: Writing a daemon in Perl...
>
>
> On Wednesday, September 24, 2003, at 12:58 PM, NIPP, SCOTT V (SBCSI)
> wrote:
>
> > I have written a group of Perl scripts that collects data and
> > transfers it to a specific server via ftp. These scripts work great.
> > I
> > also have a couple of scripts that parse the data on the server and
> > populate
> > this data into a database. Once again, these scripts are working
> > great.
> > What I would like however is to write a daemon that runs continuously
> > on the
> > database server and populates the DB information as files arrive. I
> > have
> > never even thought of writing a daemon before, and I don't even know
> > where
> > to begin looking. Any advice would be most appreciated. Thanks in
> > advance.
>
> Network Programming with Perl, an excellent book, covers this very
> topic thoroughly. I highly recommend it.
>
> James
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]