b1fca0 | 1996-11-12 | Per Hedbor | | #!/bin/sh
|
fd1295 | 1997-09-07 | Henrik Grubbström (Grubba) | | #
|
b796b5 | 1998-11-18 | Per Hedbor | | # $Id: start,v 1.54 1998/11/18 04:53:30 per Exp $
cd `dirname $0`
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
c6420b | 1998-06-02 | Henrik Grubbström (Grubba) | | VERSION=202; BETA=.b;
|
b1fca0 | 1996-11-12 | Per Hedbor | |
# Can be set with '--config-dir=DIR'
DIR=../configurations/
LOGDIR=../logs/
FILES="default"
|
3e7d3b | 1998-03-20 | Per Hedbor | | program=base_server/roxenloader.pike
|
7c6da6 | 1998-11-01 | Henrik Grubbström (Grubba) | | extra_args=""
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
3c3184 | 1998-03-01 | Per Hedbor | | # Enable threads (if available) on Solaris.
# Most other OS's have thread bugs that cause them or Roxen to crash.
if uname | grep 'SunOS' >/dev/null 2>&1; then
if uname -r | grep '5\.[5-9]' >/dev/null 2>&1; then
|
8edfa3 | 1998-08-20 | Per Hedbor | | if [ x"$1" != "x--help" ] ; then
echo 'Solaris 2.5 or later detected. Enabling threads (if available).'
fi
|
3c3184 | 1998-03-01 | Per Hedbor | | DEFINES="$DEFINES -DENABLE_THREADS"
fi
fi
|
fd1295 | 1997-09-07 | Henrik Grubbström (Grubba) | | # Roxen will create files as the initial user,
# which it expects to be able to read as the run-time user.
umask 022
|
1c4818 | 1997-03-02 | Henrik Grubbström (Grubba) | | # Pike default Master-program
|
7cb64f | 1998-01-17 | Henrik Grubbström (Grubba) | | if [ "x$PIKE_MASTER" = "x" ]; then
|
133f9f | 1998-07-08 | Martin Stjernholm | | if [ -d share/pike ]; then
|
196f04 | 1998-07-08 | Martin Stjernholm | | # This is used with localinstall
|
b796b5 | 1998-11-18 | Per Hedbor | | DEFINES="$DEFINES -I$roxendir/share/pike/include"
PIKE_MODULE_PATH="$PIKE_MODULE_PATH:$roxendir/share/pike/modules"
|
133f9f | 1998-07-08 | Martin Stjernholm | | fi
if [ -f lib/master.pike ]; then
|
b796b5 | 1998-11-18 | Per Hedbor | | DEFINES="$DEFINES -m$roxendir/lib/master.pike -I$roxendir/lib/include"
PIKE_MODULE_PATH="$PIKE_MODULE_PATH:$roxendir/lib/modules"
|
53dbe8 | 1998-03-01 | Per Hedbor | | elif [ -f lib/pike/master.pike ]; then
|
b796b5 | 1998-11-18 | Per Hedbor | | DEFINES="$DEFINES -m$roxendir/lib/pike/master.pike -I$roxendir/lib/pike/include"
PIKE_MODULE_PATH="$PIKE_MODULE_PATH:$roxendir/lib/pike/modules"
|
4fed40 | 1997-04-16 | Henrik Grubbström (Grubba) | | fi
|
95721d | 1998-05-11 | Martin Stjernholm | | export PIKE_MODULE_PATH
|
7cb64f | 1998-01-17 | Henrik Grubbström (Grubba) | | else
# This is usefull when using several different Pikes.
|
f9e206 | 1998-04-19 | Henrik Grubbström (Grubba) | | # Specify include and module paths with
# PIKE_INCLUDE_PATH and PIKE_MODULE_PATH
# they are handled automatically by the master,
# so no need to do it here.
|
7cb64f | 1998-01-17 | Henrik Grubbström (Grubba) | | DEFINES="$DEFINES -m$PIKE_MASTER"
|
d0ee18 | 1997-03-01 | Henrik Grubbström (Grubba) | | fi
|
1c4818 | 1997-03-02 | Henrik Grubbström (Grubba) | |
# Extra module-path
|
d0ee18 | 1997-03-01 | Henrik Grubbström (Grubba) | | if [ -d etc/modules ]; then
|
cf1e7c | 1997-04-19 | Henrik Grubbström (Grubba) | | DEFINES="$DEFINES -Metc/modules"
|
1c4818 | 1997-03-02 | Henrik Grubbström (Grubba) | | fi
# Extra include-path
if [ -d etc/include ]; then
|
cf1e7c | 1997-04-19 | Henrik Grubbström (Grubba) | | DEFINES="$DEFINES -Ietc/include"
|
1c4818 | 1997-03-02 | Henrik Grubbström (Grubba) | | fi
# Extra include-path (2)
if [ -d base_server ]; then
|
cf1e7c | 1997-04-19 | Henrik Grubbström (Grubba) | | DEFINES="$DEFINES -Ibase_server"
|
d0ee18 | 1997-03-01 | Henrik Grubbström (Grubba) | | fi
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
4d1429 | 1998-04-28 | Henrik Grubbström (Grubba) | | # Extra program-path
DEFINES="$DEFINES -P`pwd`"
|
b88bb5 | 1998-10-16 | Henrik Grubbström (Grubba) | | # Support for adding local pike-modules
if [ -d ../local/etc/. ]; then
# Extra module-path
if [ -d ../local/etc/modules/. ]; then
|
b796b5 | 1998-11-18 | Per Hedbor | | DEFINES="$DEFINES -M$roxendir/../local/etc/modules"
|
b88bb5 | 1998-10-16 | Henrik Grubbström (Grubba) | | fi
# Extra include-path
if [ -d ../local/etc/include ]; then
|
b796b5 | 1998-11-18 | Per Hedbor | | DEFINES="$DEFINES -I$roxendir/../local/etc/include"
|
b88bb5 | 1998-10-16 | Henrik Grubbström (Grubba) | | fi
# Extra program-path
|
b796b5 | 1998-11-18 | Per Hedbor | | DEFINES="$DEFINES -P$roxendir/../local/etc"
|
b88bb5 | 1998-10-16 | Henrik Grubbström (Grubba) | | fi
|
7e1aee | 1997-08-10 | Henrik Grubbström (Grubba) | | # Extra kludge for HPUX
# HPUX doesn't like group 60001(nobody)
if uname | grep 'HP-UX' >/dev/null 2>&1; then
echo 'WARNING: Applying kludge for HPUX. (see base_server/privs.pike)'
DEFINES="$DEFINES -DHPUX_KLUDGE"
fi
|
d0ee18 | 1997-03-01 | Henrik Grubbström (Grubba) | | pike=pike
if [ -x bin/pike ] ; then pike=bin/pike; fi
|
53dbe8 | 1998-03-01 | Per Hedbor | | if [ -x bin/roxen ] ; then pike=bin/roxen; fi
|
d8f3ff | 1998-06-18 | Henrik Grubbström (Grubba) | | if [ "x$PIKE" = "x" ]; then :; else
if [ -x "$PIKE" ]; then pike="$PIKE"; fi
fi
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
c6420b | 1998-06-02 | Henrik Grubbström (Grubba) | | gdb=no
|
b1fca0 | 1996-11-12 | Per Hedbor | | ####### END PREAMBLE
## Parse all arguments.
|
82f519 | 1997-03-02 | Per Hedbor | | ## GNU-style, long options only, except for -D, simply passed on.
parse_args() {
while [ ! c"$1" = "c" ] ; do
|
b1fca0 | 1996-11-12 | Per Hedbor | | case $1 in
|
4019f8 | 1997-03-01 | Per Hedbor | | -D*)
DEFINES="$DEFINES $1"
;;
|
82f519 | 1997-03-02 | Per Hedbor | | # Used by the 'install' script
|
a41305 | 1998-08-10 | Per Hedbor | | --truss)
pike="truss $pike"
;;
|
b1fca0 | 1996-11-12 | Per Hedbor | | --log-dir=*)
LOGDIR=`echo $1 | sed -e 's/--log-dir=//'`
;;
--config-dir=*)
DIR=`echo $1 | sed -e 's/--config-dir=//'`
|
6a8566 | 1997-04-10 | Henrik Grubbström (Grubba) | | FILES=`echo $1 | sed -e's/--config-dir=//' -e's/\.//g' -e's./..g' -e 's.-..g'`
|
b1fca0 | 1996-11-12 | Per Hedbor | | ;;
|
7c6da6 | 1998-11-01 | Henrik Grubbström (Grubba) | | --pid-file=*)
extra_args="$extra_args $1"
;;
|
8a788c | 1998-07-22 | David Hedbor | | '--debug'|'--with-debug'|'--enable-debug')
|
59f64b | 1997-01-27 | Per Hedbor | | debug=1
;;
|
8edfa3 | 1998-08-20 | Per Hedbor | | '--without-debug')
debug=-1
;;
|
8a788c | 1998-07-22 | David Hedbor | | '--fd-debug'|'--with-fd-debug'|'--enable-fd-debug')
|
cc4fdd | 1998-03-26 | Per Hedbor | | DEFINES="-DFD_DEBUG $DEFINES"
;;
|
8a788c | 1998-07-22 | David Hedbor | | '--threads'|'--with-threads'|'--enable-threads')
|
3c3184 | 1998-03-01 | Per Hedbor | | DEFINES="-DENABLE_THREADS $DEFINES"
;;
|
8a788c | 1998-07-22 | David Hedbor | | '--no-threads'|'--without-threads'|'--disable-threads')
|
3c3184 | 1998-03-01 | Per Hedbor | | DEFINES="`echo $DEFINES | sed -e 's/-DENABLE_THREADS//'`"
;;
|
8edfa3 | 1998-08-20 | Per Hedbor | | '--with-profile'|'--profile')
|
3c3184 | 1998-03-01 | Per Hedbor | | DEFINES="-DPROFILE $DEFINES"
;;
|
8edfa3 | 1998-08-20 | Per Hedbor | | '--with-file-profile'|'--file-profile')
DEFINES="-DPROFILE -DFILE_PROFILE $DEFINES"
;;
|
8a788c | 1998-07-22 | David Hedbor | | '--keep-alive'|'--with-keep-alive'|'--enable-keep-alive')
|
3c3184 | 1998-03-01 | Per Hedbor | | DEFINES="-DKEEP_ALIVE $DEFINES"
;;
|
a8135b | 1996-11-12 | Per Hedbor | | '--once')
once=1
;;
|
cbced9 | 1998-11-06 | Marcus Comstedt | | # Misspelling --once might give undesirable results, so let's accept
# some "creative" spellings... :-)
'--onve'|'--onec'|'--onev')
once=1
;;
|
c6420b | 1998-06-02 | Henrik Grubbström (Grubba) | | '--gdb')
gdb=gdb
once=1
;;
|
3e7d3b | 1998-03-20 | Per Hedbor | | '--program')
program="$2"
shift
;;
|
b796b5 | 1998-11-18 | Per Hedbor | | '--cd')
cd_to="$2"
shift
;;
|
b1fca0 | 1996-11-12 | Per Hedbor | | '--version')
|
c0ca36 | 1997-05-07 | Henrik Grubbström (Grubba) | | echo Roxen Challenger 1.`expr $VERSION / 100`$BETA`expr $VERSION % 100`
|
b1fca0 | 1996-11-12 | Per Hedbor | | exit 0
;;
'--help'|'-?')
|
8edfa3 | 1998-08-20 | Per Hedbor | | sed -e "s/\\.B/`tput 'bold' 2>/dev/null`/g" -e "s/B\\./`tput 'rmso' 2>/dev/null`/g" << EOF
.BThis command will start the Roxen serverB..
The environment variable .BROXEN_ARGSB. can be used to specify
|
82f519 | 1997-03-02 | Per Hedbor | | the default arguments.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
.BArguments:B.
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--versionB.: Output version information.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--help -?B.: This information
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--log-dir=DIRB.: Set the log directory. Defaults to .B../logsB..
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--config-dir=DIRB.: Use an alternate configuration directory
Defaults to .B../configurationB..
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--with-threadsB.: If threads are available, use them.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--without-threadsB.: Even if threads are enabled by default,
disable them.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--with-profileB.: Store runtime profiling information on
a directory basis. This information is
not saved on permanent storage, it is only
available until the next server restart
This will enable a new 'action' in the
configuration interface
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--with-file-profileB.: Like .B--with-profileB., but save information
for each and every file.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--with-keep-aliveB.: Enable keep alive in the HTTP
protocol module. This will soon be
the default. Some clients might have
problems with keepalive.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--onceB.: Run the server only once, in the foreground.
This is very useful when debugging.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--gdbB.: Run the server in gdb. Implies .B--onceB..
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--programB.: Start a different program with the roxen
pike. As an example,
.B./start --program bin/install.pikeB. will
start the installation program normally
started with .B./installB.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--with-debugB.: Enable debug
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--without-debugB.: Disable all debug
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--with-fd-debugB.: Enable FD debug.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--trussB.: (Solaris only). Run the server under
truss, shows .BallB. system calls. This is
extremely noisy, and is not intented for
anything but debug.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B--pid-file=<file>B.: Store the roxen and startscript pids in this
file. Defaults to .B/tmp/roxen_$UIDB.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
.BArguments passed to pike:B.
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B-DDEFINEB.: Define the symbol .BDEFINEB..
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B-d<level>B.: Set the runtime pike debug to level.
This only works if pike is compiled
with debug.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B-s<size>B.: Set the stack size.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B-M <path>B.: Add the path to the pike module path.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B-I <path>B.: Add the path to the pike include path.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B-dtB.: Turn of tail recursion optimization.
|
adae24 | 1998-09-18 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B-tB.: Turn on pike level tracing.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .B-t<level>B.: Turn on more pike tracing. This only
works if pike is compiled with debug.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
.BEnvironment variables:B.
|
c083c2 | 1998-09-19 | Henrik Grubbström (Grubba) | | .BROXEN_CONFIGDIRB.: Same as .B--config-dir=... B.
.BROXEN_PID_FILEB.: Same as .B--pid-file=... B.
.BROXEN_LANGB.: The default language for all language
related tags. Defaults to 'en' for english.
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
82f519 | 1997-03-02 | Per Hedbor | | EOF
tput 'rmso' 2>/dev/null
|
b1fca0 | 1996-11-12 | Per Hedbor | | exit 0
;;
*)
pass="$pass $1"
|
5e87b4 | 1997-04-09 | Henrik Grubbström (Grubba) | | ;;
|
b1fca0 | 1996-11-12 | Per Hedbor | | esac
shift
|
82f519 | 1997-03-02 | Per Hedbor | | done
}
####### END PREAMBLE
parse_args $@
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
82f519 | 1997-03-02 | Per Hedbor | | if [ ! "X$ROXEN_ARGS" = "X" ]; then
echo $$: Using $ROXEN_ARGS from ROXEN_ARGS.
parse_args $ROXEN_ARGS
fi
|
d1ff62 | 1997-07-24 | Marcus Comstedt | | if [ ! "X$pass" = "X" ] ; then set -- $pass ;fi
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
82f519 | 1997-03-02 | Per Hedbor | | echo $$: Starting the Roxen Challenger World Wide Web server.
|
b1fca0 | 1996-11-12 | Per Hedbor | |
./mkdir -p $LOGDIR/debug/
|
59f64b | 1997-01-27 | Per Hedbor | | if [ -z "$debug" ] ; then
|
fc2fcf | 1997-04-13 | Per Hedbor | | DEBUG="-DMODULE_DEBUG";
|
59f64b | 1997-01-27 | Per Hedbor | | else
|
4dfffc | 1998-07-27 | Martin Stjernholm | | DEBUG="-DDEBUG -DMODULE_DEBUG"
|
59f64b | 1997-01-27 | Per Hedbor | | fi
|
38e43b | 1998-09-12 | Henrik Grubbström (Grubba) | | if [ "x$debug" = "x-1" ] ; then
|
8edfa3 | 1998-08-20 | Per Hedbor | | DEBUG="";
|
38e43b | 1998-09-12 | Henrik Grubbström (Grubba) | | else :; fi
#
# Some useful functions
#
rotate () {
b=5;
for a in 4 3 2 1 ; do mv -f $1.$a $1.$b 2> /dev/null; b=$a; done
}
start_roxen() {
|
b796b5 | 1998-11-18 | Per Hedbor | | if [ x$DIR != xconfigurations ] ; then
args="-DROXEN $DEBUG $DEFINES $pass $program --config-dir=$DIR"
else
args="-DROXEN $DEBUG $DEFINES $pass $program"
fi
if [ x$cd_to != x ] ; then
cd $cd_to
fi
|
38e43b | 1998-09-12 | Henrik Grubbström (Grubba) | | if [ "x$gdb" = "xno" ]; then
echo "PIKE_MODULE_PATH=$PIKE_MODULE_PATH"
echo Executing $pike $args $@
$pike $args $@
else
echo Executing gdb $pike $args $@
echo >.gdbinit handle SIGPIPE nostop noprint pass
echo >>.gdbinit handle SIGUSR1 nostop noprint pass
echo >>.gdbinit handle SIGUSR2 nostop noprint pass
echo >>.gdbinit run $args $@
gdb $pike
rm .gdbinit
fi
}
#
# Now do the stuff
#
|
8edfa3 | 1998-08-20 | Per Hedbor | |
|
a8135b | 1996-11-12 | Per Hedbor | | if [ -z "$once" ] ; then
|
13c548 | 1998-07-02 | Henrik Grubbström (Grubba) | | cat << oo
Using configuration from $DIR, storing the debug log in $LOGDIR/debug/$FILES.1
You can use the configuration interface in the server to get debug info.
oo
# Try to get rid of some fd's.
# Some /bin/sh's have problems detaching otherwise.
exec >/dev/null
exec 2>/dev/null
exec </dev/null
|
9c353a | 1997-08-23 | Henrik Grubbström (Grubba) | | (while : ; do
echo $$: "Server restart at `date`"
echo $$: "Debug log in $LOGDIR/debug/$FILES.1"
rotate $LOGDIR/debug/$FILES
|
82f519 | 1997-03-02 | Per Hedbor | |
|
7c6da6 | 1998-11-01 | Henrik Grubbström (Grubba) | | start_roxen $extra_args 2>>$LOGDIR/debug/$FILES.1 1>&2
|
82f519 | 1997-03-02 | Per Hedbor | |
|
7cb64f | 1998-01-17 | Henrik Grubbström (Grubba) | | exitcode="$?"
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
7cb64f | 1998-01-17 | Henrik Grubbström (Grubba) | | if [ "$exitcode" -eq "0" ] ; then
# Clean shutdown.
echo $$: "Roxen shutdown."
exit 0
fi
if [ "$exitcode" -lt "0" ] ; then
# Signal death.
echo $$: "Roxen died of signal $exitcode. Restarting..."
else
|
b796b5 | 1998-11-18 | Per Hedbor | | # Restart. Do not sleep a few seconds before restarting.
echo $$: Roxen died. Restarting...
# sleep 1
|
b1fca0 | 1996-11-12 | Per Hedbor | | fi
|
9c353a | 1997-08-23 | Henrik Grubbström (Grubba) | | done
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
9c353a | 1997-08-23 | Henrik Grubbström (Grubba) | | echo $$: Not Reached "famous last words"
|
b1fca0 | 1996-11-12 | Per Hedbor | |
|
9c353a | 1997-08-23 | Henrik Grubbström (Grubba) | | ) < /dev/null > $LOGDIR/debug/start_$FILES.output 2>&1 &
|
82f519 | 1997-03-02 | Per Hedbor | |
|
a8135b | 1996-11-12 | Per Hedbor | | else
|
82f519 | 1997-03-02 | Per Hedbor | | echo $$: "Server restart at `date`"
|
7c6da6 | 1998-11-01 | Henrik Grubbström (Grubba) | | start_roxen $extra_args
|
a8135b | 1996-11-12 | Per Hedbor | | fi
|
fc2fcf | 1997-04-13 | Per Hedbor | |
|