Re: Copyover (syslogs)

From: Peter Ajamian (
Date: 10/29/00

"Shane P. Lee" wrote:
> I added Copyover some time back, and so far I've
> found only one side-effect that I didn't care for.
> Since Copyover bypasses, the syslog is
> never grep'ed and passed on to /log.
> This is getting to be quite annoying, since we hardly
> ever use the old shutdown commands anymore. The
> syslog file gets pretty big after a few days, and
> when I search for possible errors to fix, I have to
> 'shutdown reboot' twice to get the proper syslog.1.
> Before I go add a fork to do_copyover that emulates
> the grepping actions, has anyone out there
> in MUDLand also become annoyed by this and created a
> quick fix?

Depends on what you'd consider a quick fix.  What I did was I made it so
that the MUD will automatically shut down, run maintenance, and reboot
once every morning at a set time.  My primary reason for doing this is
to maintain the pfiles without having to manually shut thte MUD down and
run maintenance from the shell.  The automatic routine allows for far
less downtime and it also has the side effect of keeping the syslogs
relatively short as it will be restarted at least once per day.

The way I accomplished this is relatively twoo-stage.  First I created a
"shutdown maintenance" command so I could run maintenance without having
to go into the shell.  This works quite the same as the other shutdown
commands by touching a file for autorun to detect so it knows to run
maintenance before restarting the MUD.

After this I had to add in code for the MUD to automatically run the
maintenace at a specific time of day.  I actually had to double up on
this work because it is quite p[ossible that the MUD could be in two
distinct states when maintenance time rolls around.  It could be in a
normal playing state in which case I added a heartbeat function which
runs every 15 seconds and checks to see if it's maintenace time yet.

The other (more difficult) possibility is that the MUD is sleeping.
When the MUD is sleeping no code will get  executed until someone
connects to the MUD and sends a signal to the MUD which brings it out of
sleep.  The select function which is what puts the MUD to sleep has the
(previously unused) feature of being able to return after a designated
amount of time as well as being able to return when a socket is opened.
Following is the beginning section of my modified game_loop function
which accomplishes this (note this came from bpl14)...

void game_loop(int mother_desc)
  fd_set input_set, output_set, exc_set, null_set;
  struct timeval last_time, before_sleep, opt_time, process_time, now,
timeout, maint_tv;
  char comm[MAX_INPUT_LENGTH];
  struct descriptor_data *d, *next_d;
  int pulse = 0, missed_pulses = 0, maxdesc, aliased, select_val;
  extern time_t maint_time; /* already initialized to the TOD when the
MUD is to shut down for maintenance */

  /* initialize various time values */
  null_time.tv_sec = 0;
  null_time.tv_usec = 0;
  opt_time.tv_usec = OPT_USEC;
  opt_time.tv_sec = 0;

  gettimeofday(&last_time, (struct timezone *) 0);

  /* The Main Loop.  The Big Cheese.  The Top Dog.  The Head Honcho.
The.. */
  while (!circle_shutdown) {

    /* Sleep if we don't have any connections */
    if (descriptor_list == NULL) {
      log("No connections.  Going to sleep.");
      FD_SET(mother_desc, &input_set);
      /* Initialize timeval for time remaining until next maintenance */
      maint_tv.tv_sec = difftime(maint_time, time(NULL));
      maint_tv.tv_usec = 0;
      if ((select_val = select(mother_desc + 1, &input_set, (fd_set *)
0, (fd_set *) 0,
                               &maint_tv)) < 0) {
        if (errno == EINTR)
          log("Waking up to process signal.");
          perror("Select coma");
      } else if (select_val) {
        log("New connection.  Waking up.");
      } else {
        /* Shutdown for maintenance */
        log("Automatic shutdown for maintenance.");
        touch(MAINT_FILE); /* of course, MAINT_FILE contains the
filename of the file that autorun checks for maint */
        return; /* This pretty much says we wanna shut down NOW! */

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  |

This archive was generated by hypermail 2b30 : 04/10/01 PDT