Roxen.git / server / start

version» Context lines:

Roxen.git/server/start:1:   #!/bin/sh   # - # $Id: start,v 1.242 2011/03/21 00:17:43 mast Exp $ + # $Id: start,v 1.243 2012/01/17 10:52:44 grubba Exp $      ### If --silent-start is given as the first argument,   ### nothing will be printed to stdout by the script.      if [ "x$1" = "x--silent-start" ] ; then    SILENT_START="y"    shift   fi      check_owner() {
Roxen.git/server/start:741:   ####### END MySQL      #   # Some useful functions   #      cleanup_pid_file() {    [ -z "$pidfile" ] || rm $pidfile   }    + # Check if the PID in $1 is an active process. + processp() { +  if kill -0 "$1"; then return 0; fi; +  +  # Check that the cause for the failure is that the process doesn't exist. +  "$PIKE" $DEFINES -e 'return !kill('"$1"', 0) && (errno() == System.ESRCH);'; +  return; + } +    # NOTE: The following function needs to be reentrant.   signal_exit() {    test "x$once" != x2 && dp "Start script terminating."    trap "" 2 15    if [ "x$ROXEN_PID" != "x" ] && \ -  kill -0 $ROXEN_PID 2>/dev/null; then +  processp $ROXEN_PID 2>/dev/null; then    kill $ROXEN_PID 2>/dev/null && wait $ROXEN_PID 2>/dev/null    dp "Roxen WebServer shutdown."    # FIXME: Consider exiting here.    fi    if [ "x$keep_mysql" = "x" ] ; then    if [ -f "$DIR/_mysql/mysql_pid" ] ; then    mysql_pidfile="$DIR/_mysql/mysql_pid"    elif [ -f "$ROXEN_DATADIR/mysql/mysql_pid" ] ; then    mysql_pidfile="$ROXEN_DATADIR/mysql/mysql_pid"    fi    if [ "x$mysql_pidfile" != "x" ] ; then    mysql_pid="`cat $mysql_pidfile 2>/dev/null`"    dp_no_nl "Shutting down MySQL."    kill "$mysql_pid" 2>/dev/null    # Give mysql 5 minutes to shut down.    timer=""    while [ -f "$mysql_pidfile" -a \    "$timer" != "mmmmm" ] && \ -  kill -0 "$mysql_pid" 2>/dev/null; do +  processp "$mysql_pid" 2>/dev/null; do    sleep 2    timer=`echo "x$timer" | sed -e 's/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/m/'`    if [ "x$SILENT_START" != "xy" ]; then    # Progress indicator.    echo "." | tr -d '   ' >&2    fi    done    if [ "x$SILENT_START" != "xy" ]; then    echo >&2    fi -  if kill -0 "$mysql_pid" 2>/dev/null; then +  if processp "$mysql_pid" 2>/dev/null; then    dp "Shutting down MySQL the hard way."    kill -9 "$mysql_pid" 2>/dev/null    fi    if [ -f "$mysql_pidfile" ] && \    [ "$mysql_pid" = "`cat $mysql_pidfile`" ]; then    rm -f "$mysql_pidfile" 2>/dev/null    fi    fi    fi    test "x$once" != x2 && dp "Start script terminated."
Roxen.git/server/start:905:      if [ "$program" = "base_server/roxenloader.pike" ] ; then    # Starting a Roxen server. Fix the pid file.    [ -z "$pidfile" ] && pidfile="${ROXEN_PID_FILE:-$DIR/_roxen_pid}"    pass="$pass --pid-file='`echo \"$pidfile\" | sed -e \"s/'/'\\\"'\\\"'/g\"`'"    # Check for stop.    if [ "$stop"x != x ] && [ -f "$pidfile" ]    then    pids=`cat "$pidfile"`    echo "$pids" | xargs kill -  while kill -0 $pids 2>/dev/null -  do +  cat "$pidfile" | while read pid; do +  while processp $pid 2>/dev/null; do +  echo "Waiting for $pid to die." >&2    sleep 1    done -  +  done    exit    fi    # Avoid duplicate start scripts if we got a pid file.    mypid=$$    test -f "$pidfile" && {    if read roxenpid && read scriptpid; then -  if kill -0 $scriptpid 2>/dev/null; then +  if processp $scriptpid 2>/dev/null; then    dp "According to the pid file $pidfile,"    dp "there is already a start script running with pid $scriptpid. Specify "    dp "another pid file with --pid-file if this is a different server."    dp "Server not started."    : -  elif kill -0 $roxenpid 2>/dev/null; then +  elif processp $roxenpid 2>/dev/null; then    dp "According to the pid file $pidfile,"    dp "there is already a server running with pid $roxenpid, but its start "    dp "script seems to have died. You should shut it down and restart "    dp "it, since it won't restart automatically. Server not started."    :    else false; fi    else false; fi    } < "$pidfile" && exit 1    # Minor race here.    { echo "x" && echo $mypid; } > "$pidfile"