[Zope] Making Zope auto-start on Mandrake 8.2
Jack Coates
jack@monkeynoodle.org
31 Jul 2002 22:26:02 -0700
--=-c/1iEV+2aFCEPTh2Dn52
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
I forget if I found this on Zope.org or if I hacked it or what (used to
have a version where it started three separate instances, ew).
But here's my Mandrake 8.2 init script. Just put it in /etc/init.d/ and
run:
chkconfig zope on
chkconfig --list zope
On Wed, 2002-07-31 at 12:22, Paul Winkler wrote:
> On Wed, Jul 31, 2002 at 03:07:19PM -0400, working4aliving wrote:
> > I'm a newbie looking for this info. I tried to add
> > /usr/local/zope/start
> > at the end of rc.local, but it just sits there (and doesn't exit processing rc.local).
>
> You need to put the start script in the background if you want to
> run it that way.
>
> /usr/local/zope/start &
>
> --
>
> Paul Winkler
> home: http://www.slinkp.com
> "Muppet Labs, where the future is made - today!"
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
>
--
Jack Coates
Monkeynoodle: A Scientific Venture...
--=-c/1iEV+2aFCEPTh2Dn52
Content-Disposition: attachment; filename=zope.script
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-sh; name=zope.script; charset=ISO-8859-1
#!/bin/sh
#
# zope Start/Stop the Zope web-application server.
#
# chkconfig: 2345 72 72
# description: zope is a web server specifically for handling \
# HTTP requests to the Zope web-application service.
# probe: true
# Source function library.
. /etc/rc.d/init.d/functions
# Extracted from 'functions' to augment it to obtain Zope's
# watchdog and server PIDs from the ${INSTANCE_HOME}/var/Z2.pid
# file, where both the parent and child processes are recorded
# in the _same_ file. <sigh>
# A function to find the pid of a program.
pidofproc() {
# Test syntax.
if [ $# =3D 0 ] ; then
echo "Usage: pidofproc {program}"
return 1
fi
# First try the "$INSTANCE_HOME/var/Z2.pid" file
if [ -f ${INSTANCE_HOME}/var/Z2.pid ] ; then
if [ "$1" =3D "zwatchdog" ] ; then
pid=3D`sed -e 's/^\([0-9]\+\) [0-9]\+/\1/' ${INSTANCE_HOME=
}/var/Z2.pid`
else
if [ "$1" =3D "zserver" ] ; then
pid=3D`sed -e 's/^[0-9]\+ \([0-9]\+\)/\1/' ${INSTANCE_HOM=
E}/var/Z2.pid`
fi
fi
if [ "$pid" !=3D "" ] ; then
echo $pid
return 0
fi
fi
# Next try "/var/run/*.pid" files
if [ -f /var/run/$1.pid ] ; then
pid=3D`head -1 /var/run/$1.pid`
if [ "$pid" !=3D "" ] ; then
echo $pid
return 0
fi
fi
# Next try "pidof"
pid=3D`pidof -o $$ -o $PPID -o %PPID -x $1`
if [ "$pid" !=3D "" ] ; then
echo $pid
return 0
fi
}
# Extracted from 'functions' to fix a tiny bug where it uses 'pidof'
# but should be using 'pidofproc'.
status() {
# Test syntax.
if [ $# =3D 0 ] ; then
echo "Usage: status {program}"
return 1
fi
# First try "pidofproc"
pid=3D`pidofproc $1`
if [ "$pid" !=3D "" ] && ps h $pid >/dev/null 2>&1 ; then
echo "$1 (pid $pid) is running..."
return 0
else
pid=3D`pidof -o $$ -o $PPID -o %PPID -x $1`
if [ "$pid" !=3D "" ] ; then
echo "$1 (pid $pid) is running..."
return 0
fi
fi
# Next try "/var/run/*.pid" files
if [ -f /var/run/$1.pid ] ; then
pid=3D`head -1 /var/run/$1.pid`
if [ "$pid" !=3D "" ] ; then
echo "$1 dead but pid file exists"
return 1
fi
fi
# See if /var/lock/subsys/$1 exists
if [ -f /var/lock/subsys/$1 ]; then
echo "$1 dead but subsys locked"
return 2
fi
echo "$1 is stopped"
return 3
}
INSTANCE_HOME=3D/usr/local/zope
INSTANCE_NAME=3D`basename ${INSTANCE_HOME}`
# make sure starter script exists
[ -f ${INSTANCE_HOME}/start ] || exit 0
RETVAL=3D0
# See how we were called.
case "$1" in
start)
echo -n "Starting zope: "
cd ${INSTANCE_HOME}
# See if it's already running.
pid=3D`pidofproc zwatchdog`
[ -n "$pid" ] && ps h $pid >/dev/null 2>&1 && echo && exit $RETVAL
pid=3D`pidofproc zserver`
[ -n "$pid" ] && ps h $pid >/dev/null 2>&1 && echo && exit $RETVAL
rm -f ${INSTANCE_HOME}/var/Z2.pid
daemon ${INSTANCE_HOME}/start &
RETVAL=3D$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/${INSTANCE_NAME}
;;
stop)
echo -n "Shutting down zope: "
killproc zwatchdog
killproc zserver
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/${INSTANCE_NAME} ${INSTANCE_HO=
ME}/var/Z2.pid
;;
restart|reload)
$0 stop
$0 start
RETVAL=3D$?
;;
status)
status zwatchdog
[ $RETVAL -ne 0 ] && RETVAL=3D$?
status zserver
[ $RETVAL -ne 0 ] && RETVAL=3D$?
;;
probe)
# echo command to start/restart zope, only if NOT already running...
# (this is a linuxconf convention, using the probe keyword above)
if [ ! -f /var/lock/subsys/${INSTANCE_NAME} ] ; then
echo start; exit 0
fi
pid=3D`pidofproc zwatchdog`
[ -n "$pid" ] && ps h $pid >/dev/null 2>&1 && exit $RETVAL
pid=3D`pidofproc zserver`
[ -n "$pid" ] && ps h $pid >/dev/null 2>&1 && exit $RETVAL
echo restart; exit 0
;;
*)
echo "Usage: zope {start|stop|restart|status}"
exit 1
esac
exit $RETVAL
--=-c/1iEV+2aFCEPTh2Dn52--