🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nn
1 messages
1 total messages Started by Richard Steinberger Thu, 19 Mar 1992 19:54
fixing the nnmaster "stall" problem
#2599
Author: Richard Steinberger
Date: Thu, 19 Mar 1992 19:54
100 lines
3634 bytes
Kim Storm gave me a few suggestions I used to help deal with the
"stalled nnmaster" problem.  This is a condition that can occur on
NNTP client machines.  The symptom is the message that no updates have
taken place for some time when nn is started.  Kim's suggestion was to
check the age of the directory containing the ACTIVE file.  If it doesn't
stay relatively "young", kill nnmaster and restart it.

Here are two files I used to try to accomplish this:

File 1 is a Bourne shell script that I invoke from cron every 30 minutes.
There is nothing sacred about 30 minutes.  Almost any interval is OK.
File 2 is a C++ file used by file 1 to get the "age" in seconds of a 
file, in this case the /var/spool/nn directory.  This file could
easily be changed to C by replacing the lines with // in them with
standard C comments.  cerr and cout would mutate into fprintf
stderr and stdout.

Warning: I haven't yet seen a case where nnmaster has stalled again.
So, I haven't seen that it is really restarted again properly.  It's
supposed to send me email if this occurs.

--------------file--1-------------------------------------------------------
#!/bin/sh
#
# nnmaster sometimes stalls sometimes.  If the location of the directory
# where ACTIVE lives is not touched regularly, assume a stall.  
# Restart nnmaster.
#
# Ric Steinberger
# 19 March, 1992
#
STALL_AGE_LIMIT=3600             #time limit in seconds
ACTIVE_DIR=/var/spool/nn         #directory containing ACTIVE file
TOOL_DIR=/usr/tools/sys          #directory with get_file_age program

if [ `$TOOL_DIR/get_file_age $ACTIVE_DIR` -lt $STALL_AGE_LIMIT ]; then
	exit 0
fi
#
# nnmaster hasn't updated in at least STALL_AGE_LIMIT seconds
# Might as we restart it.  See /etc/rc.local for boot startup sequence.
# Try it without the -C option (consistency check) for now.
#
if [ -f /usr/local/lib/nn/nnmaster ]; then
        rm -f /usr/local/lib/nn/MPID
        /usr/local/lib/nn/nnmaster -k -l -r 20
fi
mail ric << EOF
nnmaster restarted from cron.
EOF

exit 0

-----------------file--2------------------------------------------------------

// get_file_age - Use stat to print out the age of a file.

// Usage:  get_file_age filename

#include <iostream.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/file.h>

const int EXIT_FAILURE = -1;
const int EXIT_SUCCESS =  0;

main(int argc, char *argv[])
{
  if (argc < 2)
    {
      cerr << "Usage: " << argv[0] << " filename\n";
      exit(EXIT_FAILURE);
    }

  if (access(argv[1],0))
    {
      cerr << "get_file_age: File " << argv[1] << " not found.\n";
      exit(EXIT_FAILURE);
    }

  struct stat sbuf;
  if (stat(argv[1], &sbuf))
    {
      cerr << argv[0] << ": Error return from stat call.\n";
      exit(EXIT_FAILURE);
    }

//  cout << "Status change time: " << sbuf.st_ctime << endl;

  time_t now, tnow;
  now = time(&tnow);

//  cout << "File age (secs): " << now - sbuf.st_ctime << endl;

  cout << now - sbuf.st_ctime << endl;
}
 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads