Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: open FH, "|foo" under modperl2

by Anonymous Monk
on Feb 06, 2004 at 11:53 UTC ( #327043=note: print w/replies, xml ) Need Help??

in reply to open FH, "|foo" under modperl2

I know nothing about rotatelogs but I would assume that if it is used with the CustomLog directive that Apache executes it once at startup and then pipes all log output through this one process. If you simply substituted a pipe to it in your open call then you would be executing it every time mylog() gets called, this will lead to increased overhead, not to mention the possibility that rotatelogs won't work like you want if it is repeatedly run like this (it might, for example, start a new log each time it is run rather than appending to the previous one). These problems would be solved by opening it once at startup and then just printing to it in mylog().

Yes, you can open the pipe like a file

flock only works on files (as opposed to filehandles), but if multiple processes are using the same pipe then you will probably need some sort of synchronization such as locking a sentinal file. When I say "using the same pipe" I am referring to creating the pipe outside of mylog() as mentioned earlier, but even if you were creating it in mylog() you might have multiple copies of rotatelogs writing to the same file depending on how rotatelogs works so a lock on a sentinal file would be a good idea here too.

Your last two questions were answered with the first.

Replies are listed 'Best First'.
Re: Re: open FH, "|foo" under modperl2
by BazB (Priest) on Feb 06, 2004 at 13:32 UTC

    perlfunc:flock says:

    Calls flock(2), or an emulation of it, on FILEHANDLE.
    Admittedly, I've never tried to flock anything other than a filehandle related to a physical file, however to be picky: flock _does_ work against filehandles.

    If the information in this post is inaccurate, or just plain wrong, don't just downvote - please post explaining what's wrong.
    That way everyone learns.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://327043]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2018-03-18 22:25 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (231 votes). Check out past polls.