Branch: Tag:

1998-01-17

1998-01-17 02:51:39 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Now looks at returncode to know when to restart.

Rev: server/start:1.24

1:   #!/bin/sh   # - # $Id: start,v 1.23 1997/11/19 15:38:05 grubba Exp $ + # $Id: start,v 1.24 1998/01/17 02:51:39 grubba Exp $      VERSION=201; BETA=.a;   
14:   umask 022      # Pike default Master-program + if [ "x$PIKE_MASTER" = "x" ]; then   if [ -f lib/pike/master.pike ]; then    DEFINES="$DEFINES -mlib/pike/master.pike"   else
22:    DEFINES="$DEFINES -m../pike/src/lib/master.pike"    fi   fi + else +  # This is usefull when using several different Pikes. +  DEFINES="$DEFINES -m$PIKE_MASTER" + fi      # Extra module-path   if [ -d etc/modules ]; then
57:   pike=pike   if [ -x bin/pike ] ; then pike=bin/pike; fi   if [ -x bin/roxen ] ; then pike=bin/roxen; fi + if [ -x "$PIKE" ]; then pike="$PIKE"; fi      rotate () {    b=5;
142:      if [ -z "$once" ] ; then    (while : ; do -  sdfile="/tmp/Roxen_Shutdown_$$" -  rm $sdfile -  if [ -f "$sdfile" ] ; then -  cat << oo - WARNING: - A shutdown file '('$sdfile')' is present, and the file cannot be - removed by this script. -  - Please remove this file, or you might be unable to shut down Roxen in - the future. -  - The file: - oo -  ls -l $sdfile -  noshutdown="yes" -  else -  noshutdown="" -  fi -  +     echo $$: "Server restart at `date`"    echo $$: "Debug log in $LOGDIR/debug/$FILES.1"    rotate $LOGDIR/debug/$FILES       start_roxen 2>>$LOGDIR/debug/$FILES.1 1>&2    -  if [ -z "$noshutdown" ] ; then -  if [ -f "$sdfile" ] ; then +  exitcode="$?"    - # A shutdown file. This is only done if Roxen cannot kill this script - # for some reason, the most common beeing the lack of a seteuid() - # function, in which case Roxen will write this file. - # - # The contents of the file is the actual PID Roxen got when it was - # started. This could be used to verify that this was the correct - # shutdown file, but since it is extremely unlikely that two - # start-scripts get the same PID, this is not done. -  -  echo $$: Server shutdown file detected. Shutting down -  rm "$sdfile" -  if [ -f "$sdfile" ] ; then -  echo $$: "Failed to remove '"$sdfile"'. This could be a problem" +  if [ "$exitcode" -eq "0" ] ; then +  # Clean shutdown. +  echo $$: "Roxen shutdown."    exit 0 -  else -  exit 0 +     fi -  fi -  fi +  if [ "$exitcode" -lt "0" ] ; then +  # Signal death. +  echo $$: "Roxen died of signal $exitcode. Restarting..." +  else +  # Restart. Sleep a few seconds before restarting.    echo $$: Roxen died. Restarting in 5 seconds... -  # Don't take all available CPU if Roxen keeps dieing. +     sleep 5 -  +  fi    done       echo $$: Not Reached "famous last words"