agh has asked for the wisdom of the Perl Monks concerning the following question:
I need to start a postgres daemon and redirrect it's STDERR and STDOUT to a logfile rotator (can't mix them). Here's a sketch of what I'm thinking:
What I'm wondering is about efficiency. Is there a better way to do this? I'd very much like to exec the final call to the postmaster daemon so that I don't have the overhead of a perl instance. Is is possible to detach these processes? Should I be writing this in shell?use IPC::Open3; our $rotatelogs_bin = ''; our $rotate_size = '10M'; # must end with M, see rotatelogs docs our $logdir = '/home/ahammond/logtest/log'; our $pg_bin = '/home/ahammond/logtest/belcher.pl'; our $pg_args = ''; # start by opening stdout and stderr loggers open (STDOUTLOG, "| $rotatelogs_bin $logdir/stdout.log $rotate_size") or die "Can't open stdoutlog: $!\n"; open (STDERRLOG, "| $rotatelogs_bin $logdir/stderr.log $rotate_size") or die "Can't open stderrlog: $!\n"; # filehandle manipulation here? our $pid = open3 (\*STDIN, \*STDOUTLOG, \*STDERRLOG, $pg_bin, $pg_args);
Drew
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: efficiently dispatching loggers for daemon
by bageler (Hermit) on Mar 08, 2004 at 23:26 UTC | |
by agh (Novice) on Mar 09, 2004 at 22:21 UTC | |
by bageler (Hermit) on Mar 12, 2004 at 19:34 UTC | |
|
Re: efficiently dispatching loggers for daemon
by bageler (Hermit) on Mar 23, 2004 at 23:46 UTC |