Roxen.git / server / start

version» Context lines:

Roxen.git/server/start:1:   #!/bin/sh   # - # $Id: start,v 1.249 2012/09/27 12:44:12 grubba Exp $ + # $Id$      ### 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:115:      # Default verbosity level.   verbose=1      # Do not default to using a relative path.   roxendir="`pwd`"      # No debug by default.   debug=-1    + # Don't attempt to stop a running server by default. + stop="" +  + # Attempt to start the server by default. + start=1 +    # Locate Pike binary.   find_pike      # Source environment   setup_environment      ####### BEGIN ARGUMENT PARSING         DEFINES="$DEFINES -DRAM_CACHE -DNEW_RAM_CACHE -DHTTP_COMPRESSION"
Roxen.git/server/start:331:    verbose=0    ;;    '--verbose'|'-v')    verbose=2    debug=1    ;;    '--remove-dumped')    remove_dumped=1;    ;;    '--stop') -  stop=1; +  stop="TERM"; +  start="";    ;; -  +  '--restart') +  stop="TERM"; +  start=1; +  ;; +  '--signal') +  stop="$2" +  shift +  start=""; +  ;;       '--once')    once=${once:-1}    debug=0    ;;   # Misspelling --once might give undesirable results, so let's accept   # some "creative" spellings... :-)    '--onve'|'--onec'|'--onev'|'--ocne')    once=${once:-1}    debug=0
Roxen.git/server/start:503:    .B--self-test-quietB.: Runs a testsuite, only report errors.    .B--self-test-dir=DIRB.: Use this self test directory instead of    the default .Betc/testB. directory.       .B--onceB.: Run the server only once, in the foreground.    This is very useful when debugging. Implies    --module-debug.       .B--stopB.: Stop the server.    +  .B--restartB.: Stop the server, and then restart it. +  +  .B--signalB.: Send the specified signal to the running +  Roxen process. +     .B--keep-mysqlB.: Do not shut down MySQL process when exiting    the start script. Useful during development    or any other scenario where the start script    is frequently terminated.       .B--gdbB.: Run the server in gdb. Implies .B--onceB..       .B--valgrind[=valgrind args]B.: Run the server in valgrind. Implies .B--onceB..       .B--programB.: Start a different program with the Roxen
Roxen.git/server/start:1044:    dp "Executing $pike $valgrind $args"    eval "\"$pike\" \"$valgrind\" $args"    else    dp "Executing valgrind $pike $args"    valgrind `expr "$valgrind" : '--valgrind=\(.*\)'` "$pike"    fi    fi    cleanup_roxen_pid_file   }    + # <pid> <signal> <type> <canonicalconf> <description> + stop_roxen() + { +  if roxenp "$1" "$3" "$4"; then +  if [ "$2" = "TERM" ]; then +  dp "Shutting down the $5..." +  kill "$1" || exit 1 +  while processp "$1" 2>/dev/null; do +  echo "Waiting for $5 $1 to die." >&2 +  sleep 1 +  done +  else +  kill "-$2" "$1" || exit 1 +  fi +  return 0 +  fi +  return 1 + }      #   # Now do the stuff   #      trap signal_exit 2 15   trap "" 1      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 ]    then    if [ -f "$pidfile" ]; then    if read roxenpid && read scriptpid; then    problems="" -  if roxenp "$scriptpid" "start" "$canonicalconf"; then -  dp "Shutting down the start script..." -  kill "$scriptpid" -  while processp $pid 2>/dev/null; do -  echo "Waiting for start script $pid to die." >&2 -  sleep 1 -  done +  # NB: No need to shut down the start-script +  # if we're going to do a restart. +  if [ "$start"x = x -a "$stop" = "TERM" ]; then +  if stop_roxen "$scriptpid" "TERM" "start" "$canonicalconf" "start script"; then +  :    else    problems="nostart"    fi -  +  fi    # NB: At this point the original start script has    # often already shut down the server, but... -  if roxenp "$roxenpid" "server" "$canonicalconf"; then -  dp "Shutting down the server..." -  kill "$roxenpid" -  while processp $roxenpid 2>/dev/null; do -  echo "Waiting for roxen $roxenpid to die." >&2 -  sleep 1 -  done +  if stop_roxen "$roxenpid" "$stop" "server" "$canonicalconf" "Roxen server"; then +  :    else    problems="$problems:noserver"    fi    if [ "$problems" = "nostart:noserver" ]; then    dp "There is a pid file $pidfile,"    dp "but the corresponding processes do not exist,"    dp "or are not associated with this configuration."    dp "Stale pid file? Deleting the pid file."    rm "$pidfile"    :    fi -  +  if [ "$problems:$start" = "nostart:1" ]; then +  dp "The listed start script was dead. Starting a new one." +  : +  fi    else    dp "There is a pid file $pidfile,"    dp "but it seems to be truncated."    exit 1    fi < "$pidfile"    else    dp "The pid file $pidfile does not exist."    dp "The server is probably not running." -  +  if [ "$stop" != "TERM" ]; then +  exit 1    fi -  exit +     fi -  +  if [ "$start"x = x ]; then +  exit 0 +  fi +  fi    # Avoid duplicate start scripts if we got a pid file. -  test -f "$pidfile" && { +  if [ -f "$pidfile" ]; then +  {    if read roxenpid && read scriptpid; then    if roxenp "$scriptpid" "start" "$canonicalconf" 2>/dev/null ; then -  +  if [ "$stop"x = x ]; 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." -  : +  exit 1 +  fi +  dp "The old start script (pid $scriptpid) should now restart the server." +  exit 2    elif roxenp "$roxenpid" "server" "$canonicalconf" 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 +  exit 1 +  fi +  fi +  } < "$pidfile" || { +  # NB: The exits above just exit the subshell used for the +  # redirect. Adjust the exit codes and exit for real. +  [ "$?" = "2" ]; +  exit; +  } +  fi    # Minor race here.    lock_pid_file $start_pid "start" "$canonicalconf"    { echo "x" && echo $start_pid; } > "$pidfile"    trap cleanup_start_pid_file 0   fi      PIKEVERSION="`\"$pike\" --version 2>&1|head -1`"   LS="`ls -lL \"$pike\" 2>/dev/null`"   LS="$LS `find etc/modules -ls 2>/dev/null`"   LS="$LS `find base_server -ls 2>/dev/null`"