[PATCH] innfeed does not reopen (rotated) log file

Florian Schlichting fschlich at cis.fu-berlin.de
Thu Mar 28 09:55:54 UTC 2013


Hi Julien,

thanks for your patch, and sorry for taking so long to really look at
it:

> > 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.

well it does indeed solve the new issue well, but it doesn't touch the
original issue as innfeed in funnel-file mode is a standalone daemon
that doesn't get restartet when innd flushes the funnel-file. So I
revisited your earlier suggestion to add a call to openLogFile() to the
sighup handler (sigusr1 is already used for increasing debug level), and
this is what I'm successfully running with now:

==========
Subject: [PATCH] innfeed, scanlogs: reopen log files on sighup

The recent patch to flush exploder and process channels in innd, and to
send 'ctlinnd flushlogs' again after log rotation solved the problem of
controlchan or ninpaths holding open an already deleted errlog file.
However this does not yet solve the original issue with innfeed.log when
innfeed is run as a standalone daemon via a funnel-file.

This patch implements the changes suggested by Julien Elie in January
2013, to add an openLogFile() call to the sighup handler. The sigusr1
handler is not available, as it is already used to increase / decrease
the debugging level along with sigusr2. Also, reopening the log after
re-reading the configuration might be a good idea anyway, as the log
file location may have been changed.

Additionally, call sighup on the innfeed pid in scanlogs, and document
the changes briefly in innfeed(8) / innfeed.conf(5).
---
 doc/pod/innfeed.conf.pod |  1 +
 doc/pod/innfeed.pod      |  2 +-
 innfeed/main.c           |  3 +++
 scripts/scanlogs.in      | 24 ++++++++++++++++++++++++
 4 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/doc/pod/innfeed.conf.pod b/doc/pod/innfeed.conf.pod
index 3702c12..660c1c3 100644
--- a/doc/pod/innfeed.conf.pod
+++ b/doc/pod/innfeed.conf.pod
@@ -692,6 +692,7 @@ changed (although note that I<bindaddress> and I<bindaddress6> changes
 will only affect new connections).
 
 Any new peers are added and any missing peers have their connections closed.
+The log file is reopened.
 
 =head1 EXAMPLE
 
diff --git a/doc/pod/innfeed.pod b/doc/pod/innfeed.pod
index 3604f2f..ab9bd86 100644
--- a/doc/pod/innfeed.pod
+++ b/doc/pod/innfeed.pod
@@ -141,7 +141,7 @@ on the command line, and will reopen it (see funnel file description above).
 B<innfeed> with catch SIGINT and will write a large debugging snapshot of
 the state of the running system.
 
-B<innfeed> will catch SIGHUP and will reload the config file.
+B<innfeed> will catch SIGHUP and will reload the config and log file.
 See innfeed.conf(5) for more details.
 
 B<innfeed> will catch SIGCHLD and will close and reopen all backlog files.
diff --git a/innfeed/main.c b/innfeed/main.c
index 3b27a65..9851edc 100644
--- a/innfeed/main.c
+++ b/innfeed/main.c
@@ -572,6 +572,9 @@ static void sighup (int sig UNUSED)
     }
 
   configHosts (talkToSelf) ;
+
+  notice ("ME reloading log file %s", logFile) ;
+  openLogFile() ;
 }
 
 static void sigemt (int sig UNUSED)
diff --git a/scripts/scanlogs.in b/scripts/scanlogs.in
index cba8311..225232d 100644
--- a/scripts/scanlogs.in
+++ b/scripts/scanlogs.in
@@ -25,12 +25,18 @@ CONTROLBATCH=${MOST_LOGS}/controlbatch.log
 INNFEEDCONF=${PATHETC}/innfeed.conf
 if [ -f "${INNFEEDCONF}" ]; then
     INNFEEDLOG=`${AWK} '{gsub(/:|#/, " & ")} {if ($1 == "log-file" && $2 == ":") print $3}' ${INNFEEDCONF}`
+    INNFEEDPIDFILE=`${AWK} '{gsub(/:|#/, " & ")} {if ($1 == "pid-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"
+INNFEEDPID=
+for F in "${INNFEEDPIDFILE}" ; do
+    test -f "${PATHRUN}/${F}" && INNFEEDPID=`cat "${PATHRUN}/${F}"`
+done
+test -z "${INNFEEDPID}" && test -f "${PATHRUN}/innfeed.pid" && INNFEEDPID=`cat "${PATHRUN}/innfeed.pid"`
 NNTPSEND=${MOST_LOGS}/nntpsend.log
 PERLNOCEM=${MOST_LOGS}/perl-nocem.log
 SENDIHAVE=${MOST_LOGS}/send-ihave.log
@@ -121,6 +127,15 @@ if ${ROTATE} ; then
 	rm -f ${LOCK}
 	exit 1
     fi
+    if [ ! -z $INNFEEDPID ]; then
+        OUTPUT=`kill -HUP $INNFEEDPID 2>&1`
+        if [ "x$OUTPUT" != "x" ]; then
+            echo "$OUTPUT"
+            echo 'Cannot flush innfeed logs.'
+            rm -f ${LOCK}
+            exit 1
+        fi
+    fi
 
     ##  Make sure these .old files exist, in case innd is down.
     for F in ${LOG} ${ERRLOG} ; do
@@ -169,6 +184,15 @@ if ${ROTATE} ; then
         rm -f ${LOCK}
         exit 1
     fi
+    if [ ! -z $INNFEEDPID ]; then
+        OUTPUT=`kill -HUP $INNFEEDPID 2>&1`
+        if [ "x$OUTPUT" != "x" ]; then
+            echo "$OUTPUT"
+            echo 'Cannot flush innfeed logs.'
+            rm -f ${LOCK}
+            exit 1
+        fi
+    fi
 
     ${PAUSED} && ctlinnd -s go "Flushing log and syslog files" 2>&1
 

Florian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5565 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/inn-workers/attachments/20130328/68071eb7/attachment.bin>


More information about the inn-workers mailing list