Sven Willenberger sven
Mon Aug 15 16:38:56 PDT 2005
On Sat, 2005-08-13 at 11:08 -0700, Mischa Sandberg wrote:
> > Date: Fri, 12 Aug 2005 16:11:11 -0400
> > From: Sven Willenberger <sven at dmv.com>
> > Subject: [Slony1-general] Slony appears to restart every 11 minutes
> > 	and log	rotation
> > To: slony1-general at gborg.postgresql.org
> Message-ID: <1123877471.5149.35.camel at lanshark.dmv.com>
> > 
> > I have been banging my head over slony log rotation for quite some
> > time now and I am at a loss. Here is the situation:
> > 
> > I have 2 ways I can start slony:
> > 1) su slony -c "/usr/local/bin/slon -p /var/run/slon/slon.pid -d 2
> > T1 dbname=thedb > /usr/local/etc/slony/slony.out 2>&1 &"
> > 2) su slony -c "/usr/local/bin/slon -f /usr/local/etc/slon.conf
> > > /dev/null 2>&1 &"
> > 
> > Both of these methods will start up slon, background it so as not to
> > spew messages to console and get tied to tty, and log it (either to
> > the slony.out file in case #1, or /var/log/slony.log via syslog in > >
> > case #2).
> > 
> > With method 1, if I use newsyslog to rotate slony.out (or manually
> > rotate it), issuing a kill -HUP to to /var/run/slon/slon.pid
> > restarts the process but it will not log to the new file, it actually
> logs to slony.out.0 -- i.e. it appears to latch onto the inode number of
> the logfile and will not renew it during a sighup. 
> 
> This is true: if you redirect output, the SHELL opens your .out file,
> once, and slon doesn't even know the name of that file. 
>  

Hadn't thought about that fact ... that would explain the -HUP situation
perfectly then.

> > With method 2, I seem to have a case whereby slon is not aware of
> > its listeners or something similar and keeps "restarting":
> > Aug 12 11:52:09 server slon[89926]: [29-16] CONFIG main: slon
> > version
> > 1.1.0 starting up
> > Aug 12 11:52:09 server slon[89926]: [30-16] CONFIG main: slon
> ...
> > Also, with method 2, at each restart interval the number of entries
> > of
> > "cleanupThread" increases by one; i.e. after the first restart, 2
> > cleanupThread entries, the next restart had 4, the next had 6, the
> > next
> > restart had 8 and so on. 
> Now that looks like a real bug.

Should I report it as such? If not, any ideas on helping the devs with
more/better datapoints or debugging ideas?

> > Either way, at the moment I have no automagic way of
> > rotating
> > logfiles that does not end up in some anomalies. Any ideas here?
> 
> Since you're happy with logging by redirecting output to a file, I'll
> assume the following is acceptable ...
> 
Actually I would much prefer to use the syslog system as I am not a huge
fan of redirecting stdout to logfiles.

> If you want, you can implement log rotation with a one-line shell
> script. Something like this (I have no Unix box at the moment to test
> this first, so bear with me on typos):
> 
> $ (slon ... | while read; do echo $REPLY >mylog.$(date +%W); done) &
> 
> (If I recall correctly, "date +%W" returns the day-of-the-week. Choose
> your granularity and cycle as you will; a new log every hour, for the
> last 30 days.

`date +%A` for day of week :-)

> slon doesn't log so much stuff (at -d0) that opening a file per line is
> a real kill. If you feel that's a concern, post again, and I'll post a
> small "C" program that does the rotation.
> 

The shell command you posted above does work fine. I will try this and
compare to using apache's rotatelogs utility as suggested in another
reply in this thread.

Thanks again,

Sven



More information about the Slony1-general mailing list