[PATCH] innfeed does not reopen (rotated) log file
Julien ÉLIE
julien at trigofacile.com
Sun Feb 3 22:05:43 UTC 2013
Hi Florian,
> Related to the original issue, yesterday I noticed that ninpaths and
> controlchan have a deleted log/OLD/errlog on stdout and stderr. Perhaps
> 'ctlinnd flushlogs' as used in scanlogs should also cause flushing of
> all channel / exploder feeds?
Would the following patch suit you?
I believe it takes into account this new issue as well as the main problem
that initiated your thread.
When I run "ctlinnd flushlogs", I now have:
Feb 3 23:04:11 news innd: SERVER flushlogs running
Feb 3 23:04:11 news innd: controlchan! flush
Feb 3 23:04:11 news innd: innfeed! flush
Feb 3 23:04:11 news innd: inpaths! flush
Feb 3 23:04:11 news innd: source-archive! flush
Feb 3 23:04:11 news innd: nocem! flush
Index: doc/pod/ctlinnd.pod
===================================================================
--- doc/pod/ctlinnd.pod (révision 9454)
+++ doc/pod/ctlinnd.pod (copie de travail)
@@ -150,7 +150,8 @@
Close the news and error log files and rename them to add C<.old> to the
file name, then open fresh news and error logs. The F<active> file and
-history database are also flushed to disk.
+history database are also flushed to disk. Exploder and process channels
+are reopened so that they properly take into account the new log files.
=item go I<reason>
Index: innd/cc.c
===================================================================
--- innd/cc.c (révision 9454)
+++ innd/cc.c (copie de travail)
@@ -629,11 +629,14 @@
/*
-** Flush the log files.
+** Flush the log files as well as exploder and process channels.
*/
static const char *
CCflushlogs(char *unused[])
{
+ SITE *sp;
+ CHANNEL *cp;
+ int i;
unused = unused; /* ARGSUSED */
if (Debug)
@@ -643,6 +646,15 @@
syslog(L_NOTICE, "%s flushlogs %s", LogName, CCcurrmode());
ReopenLog(Log);
ReopenLog(Errlog);
+ /* Flush exploder and process channels so that they take into account
+ * the new log files. */
+ for (sp = Sites, i = nSites; --i >= 0; sp++) {
+ if (((cp = sp->Channel) != NULL)
+ && ((cp->Type == CTexploder) || (cp->Type == CTprocess))) {
+ SITEflush(sp, true);
+ syslog(L_NOTICE, "%s flush", sp->Name);
+ }
+ }
return NULL;
}
Index: scripts/scanlogs.in
===================================================================
--- scripts/scanlogs.in (révision 9454)
+++ scripts/scanlogs.in (copie de travail)
@@ -22,12 +22,21 @@
## Where these programs, if used, write their logs.
## We also have to find innfeed's log file.
CONTROLBATCH=${MOST_LOGS}/controlbatch.log
+INNFEEDCONF=${PATHETC}/innfeed.conf
+if [ -f "${INNFEEDCONF}" ]; then
+ INNFEEDLOG=`${AWK} '{gsub(/:|#/, " & ")} {if ($1 == "log-file" && $2 == ":") print $3}' ${INNFEEDCONF}`
+fi
+INNFEED=
+for F in "${INNFEEDLOG}" ; do
+ test -f "${MOST_LOGS}/${F}" && INNFEED="${INNFEED} ${MOST_LOGS}/${F}"
+done
+test -z "${INNFEED}" && test -f "${MOST_LOGS}/innfeed.log" && INNFEED="${MOST_LOGS}/innfeed.log"
NNTPSEND=${MOST_LOGS}/nntpsend.log
PERLNOCEM=${MOST_LOGS}/perl-nocem.log
SENDIHAVE=${MOST_LOGS}/send-ihave.log
SENDNNTP=${MOST_LOGS}/send-nntp.log
SENDUUCP=${MOST_LOGS}/send-uucp.log
-LIVEFILES="${CONTROLBATCH} ${NNTPSEND} ${PERLNOCEM} ${SENDIHAVE} ${SENDNNTP} ${SENDUUCP}"
+LIVEFILES="${CONTROLBATCH} ${INNFEED} ${NNTPSEND} ${PERLNOCEM} ${SENDIHAVE} ${SENDNNTP} ${SENDUUCP}"
## Where news.daily places expire output, unless noexplog was used.
EXPLOG=${MOST_LOGS}/expire.log
@@ -102,6 +111,9 @@
ctlinnd -s logmode
PAUSED=false
ctlinnd -s pause "Flushing log and syslog files" 2>&1 && PAUSED=true
+
+ # First, flush log files to be sure everything has been recorded
+ # before rotating them.
OUTPUT=`ctlinnd flushlogs 2>&1`
if [ "$OUTPUT" != "Ok" -a "$OUTPUT" != "In debug mode" ]; then
echo "$OUTPUT"
@@ -148,6 +160,16 @@
## Tally control messages if we logged them.
test -n "${CONTROL_DATA}" && cat ${CONTROL_DATA} | ${TALLY_CONTROL}
+ # Flush again log files so that freshly rotated new log files
+ # are properly taken into account.
+ OUTPUT=`ctlinnd flushlogs 2>&1`
+ if [ "$OUTPUT" != "Ok" -a "$OUTPUT" != "In debug mode" ]; then
+ echo "$OUTPUT"
+ echo 'Cannot flush logs.'
+ rm -f ${LOCK}
+ exit 1
+ fi
+
${PAUSED} && ctlinnd -s go "Flushing log and syslog files" 2>&1
cd ${OLD}
--
Julien ÉLIE
« Il faut mettre un frein à l'immobilisme. »
More information about the inn-workers
mailing list