[PATCH] innfeed does not reopen (rotated) log file
Julien ÉLIE
julien at trigofacile.com
Thu May 30 20:08:07 UTC 2013
Hi Florian,
> Subject: [PATCH] innfeed, scanlogs: reopen log files on sighup
Don't worry; I have been trying different variations of your kind patch for a few days. (Thanks for having also attached an update for the documentation!)
> --- a/scripts/scanlogs.in
> +++ b/scripts/scanlogs.in
> @@ -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
I believe exiting should not be forced in case a problem occurs when trying to sighup innfeed.
Otherwise, rotation is half-done, and innd remains paused...
In my daily reports, I indeed once saw:
/home/news/bin/scanlogs: line 171: kill: (4240) - Aucun processus de ce type
Cannot flush innfeed logs.
ctlinnd: Must be running
[...]
I think the following change is enough.
I will run it a few days more before committing it to STABLE (therefore fixing the current rotation issue).
As for CURRENT, the prerotatelog/postrotatelog new commands will allow to fix all the bugs you mentioned.
--- scripts/scanlogs.in (révision 9463)
+++ scripts/scanlogs.in (copie de travail)
@@ -25,12 +25,18 @@
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
@@ -112,8 +118,8 @@
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.
+ ## 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"
@@ -160,14 +166,9 @@
## 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
+ ## Send a HUP signal to innfeed so that it reopens its log files.
+ if [ ! -z ${INNFEEDPID} ]; then
+ kill -HUP ${INNFEEDPID} > /dev/null 2>&1
fi
${PAUSED} && ctlinnd -s go "Flushing log and syslog files" 2>&1
In case you see something wrong or have been running fine a new version
of your original patch, do not hesitate to tell.
--
Julien ÉLIE
« A program should always respond to the user in the way that
astonishes him least. » (Plauger's Law of Least Astonishment)
More information about the inn-workers
mailing list