Managing the servers

The FATMEN servers are started automatically at boot-time. This is done by adding the following line to the file /etc/inittab.

fatmen:2:wait:/etc/rc.fatmen > /dev/console 2>&1 # Start Fatmen

The file rc.fatmen is show below:

                             rc.fatmen
                                  

#!/bin/sh
#
#               Start FATMEN servers
#
#
if [ -x /u/jamie/bin/fatstart ]
then
        echo Start FATMEN servers ...
        su - jamie /u/jamie/bin/fatstart 2>&1
fi

Normally, no other operation is required. Should it be necessary to stop the servers, the following script may be used:

                              fatstop
                                  

#!/bin/ksh
#
#   Stop all FATMEN servers that are running and create a
#   file 'restart_fat' in the CWD that can be used to restart them.
#
stop=" "
run=" "
nolog=" "
noscr=" "
b="."
d=`date`
#
#   Ensure that variables are defined...
#
if [ -f restart_fat ]
   echo Remove old restart_fat file...
   then rm -i restart_fat
fi
for i in /fatmen/fm*
   do
typeset -u fatgrp
typeset -l fatman
fatpath=$i
fatgrp=`basename $i`
fatman=$fatgrp
eval $fatgrp=$fatpath;export $fatgrp
#
# and stop those servers that are running...
#
if [ -x $i/fatserv ]
   then
#
# does a log file exist?
#
   if [ -f /fatmen/$fatgrp.log ]
      then
      echo Log file exists for $fatgrp - looking for existing process
      log=$log$b$fatgrp
      pid=`cat /fatmen/$fatgrp.log | awk 'printf "%s
n",$13'`
      if (test $pid)
         then
         echo Looking for server process for $fatgrp
         if(ps -ae  | grep -s $pid )
            then
            echo FATSRV running PID = $pid
            run=$run$b$fatgrp
            echo rm /fatmen/$fatman/todo/signal.stop >> restart_fat
            echo Server stopped at $d > /fatmen/$fatman/todo/signal.stop
            else
            echo No existing server found for $fatgrp
            echo Removing old log file...
            rm   /fatmen/$fatgrp.log
            if [ -f $i/todo/signal.stop ]
               then echo signal.stop file found!
               rm $i/todo/signal.stop
               echo '(removed)'
            fi
         fi
      fi
   fi
fi
done
echo
echo Log files found for $log | tr '.' ' '
echo Servers already running for $run | tr '.' ' '
echo fatstart >> restart_fat
if [ -f restart_fat_fat ]
   then chmod +x restart_fat_fat
   echo restart reservers by typing restart_fat
fi

Should a server abend, it can be restarted (after curing the problem) by rerunning the fatstart script that is invoked at boottime.