[Zope] Startup script for Zope 2.x on RedHat Linux 6.0
Gregor Hoffleit
flight@mathi.uni-heidelberg.de
Mon, 30 Aug 1999 21:55:24 +0200
--k1lZvvs/B4yU6o8G
Content-Type: text/plain; charset=us-ascii
On Mon, Aug 30, 1999 at 03:30:00PM -0000, Suder Steen SFS wrote:
> Hi,
>
> I'm looking for a script to start my Zope system on a RH6
> system.
>
> The "start" script is nice, but it doesn't detach from the
> console.
>
> Does anyone have an example, a working script or
> suggestions?
For the Zope Debian packages, I created an alternative wrapper around z2.py
in the tradition of Apache's apachectl. You can find it attached to this mail.
It has some glitches, but it's a start.
Gregor
--k1lZvvs/B4yU6o8G
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=zopectl
#!/bin/sh
#
# /usr/sbin/zopectl
#
# Written by Gregor Hoffleit <flight@debian.org> for the Debian Zope package.
#
# License: Feel free to use, share and modify this code as you like.
#
#
# This is a comfortable replacement for Zope's start and stop scripts
# It let's you start, stop, restart and examine a Zope process managed
# by a zdaemon.
#
OPTION=$1
shift
#
# You might want to modify the following settings (the defaults are
# valid for Debian's Zope installation):
#
ZOPE_HOME=/usr/lib/zope
INSTANCE_HOME=/var/lib/zope
zdaemon_pidfile=$INSTANCE_HOME/var/zProcessManager.pid
zdaemon_logfile=$INSTANCE_HOME/var/Z2_debug.log
zope_pidfile=$INSTANCE_HOME/var/Z2.pid
zope_logfile=$INSTANCE_HOME/var/Z2.log
PYTHONHOME=$ZOPE_HOME
export INSTANCE_HOME PYTHONHOME
test_zdaemon() {
if [ -f $zdaemon_pidfile ]; then
zdaemon_pid=`cat $zdaemon_pidfile`
if [ ! "x$zdaemon_pid" = "x" ] && kill -0 $zdaemon_pid 2>/dev/null; then
zdaemon=1
true
else
zdaemon=-1
rm -f $zdaemon_pidfile
false
fi
else
zdaemon=0
false
fi
}
test_zope() {
if [ -f $zope_pidfile ]; then
zope_pid=`cat $zope_pidfile | cut -d' ' -f2`
if [ ! "x$zope_pid" = "x" ] && kill -0 $zope_pid 2>/dev/null; then
zope=1
true
else
zope=-1
false
fi
else
zope=0
false
fi
}
start_zdaemon() {
# /usr/sbin/zope-z2 -D $@ \
# >>$zdaemon_logfile 2>>$zdaemon_logfile &
/usr/sbin/zope-z2 $@
}
stop_zdaemon() {
test_zdaemon
if [ $zdaemon -eq 1 ]; then
kill $zdaemon_pid 2>/dev/null && true
test_zdaemon
if [ $zdaemon -eq -1 ]; then
rm -f $zdaemon_pidfile
fi
else
if [ $zdaemon -eq -1 ]; then
rm -f $zdaemon_pidfile
echo "Removed stale zdaemon pidfile (pid $zdaemon_pid)."
fi
fi
}
stop_zope() {
test_zope
if [ $zope -eq 1 ]; then
kill $zope_pid 2>/dev/null && true
test_zope
if [ $zope -eq -1 ]; then
rm -f $zope_pidfile
fi
else
if [ $zope -eq -1 ]; then
rm -f $zope_pidfile
echo "Removed stale zope pidfile (pid $zope_pid)."
fi
fi
}
case $OPTION in
status)
test_zdaemon
test_zope
if [ $zdaemon -eq 1 ]; then
if [ $zope -eq 1 ]; then
echo "Zope running (pids $zdaemon_pid, $zope_pid)."
else
echo "Zope (re)starting (zdaemon pid $zdaemon_pid)."
fi
else
if [ $zope -eq 1 ]; then
echo "Found zope process (pid $zope_pid), but no zdaemon."
else
echo "Zope not running."
fi
fi
;;
start)
test_zdaemon
test_zope
if [ ! $zdaemon -eq 1 ] && [ ! $zope -eq 1 ]; then
start_zdaemon
echo "Zope started."
else
if [ $zdaemon -eq 1 ] && [ $zope -eq 1 ]; then
echo "Zope already running."
false
else
if [ $zdaemon -eq 1 ]; then
echo "Zope currently restarting."
else
echo "Only z2 running. This should not happen."
fi
false
fi
fi
;;
stop)
test_zdaemon
test_zope
if [ $zdaemon -eq 0 ] && [ $zdaemon -eq 0 ]; then
echo "Zope not running."
not_running=1
else
not_running=0
fi
if [ $zdaemon -eq 1 ]; then
stop_zdaemon
echo "zdaemon process killed (pid $zdaemon_pid)."
else
if [ $zdaemon -eq -1 ]; then
rm -f $zdaemon_pidfile
echo "Removed stale zdaemon pidfile (pid $zdaemon_pid)."
fi
fi
test_zope
if [ $zope -eq 1 ]; then
stop_zope
echo "zope process killed (pid $zope_pid)."
else
if [ $zope -eq -1 ]; then
rm -f $zope_pidfile
echo "Removed stale zope pidfile (pid $zope_pid)."
fi
fi
if [ $not_running -eq 0 ]; then
echo "Zope stopped."
fi
;;
restart)
test_zdaemon
test_zope
if [ ! $zdaemon -eq 1 ] && [ ! $zope -eq 1 ]; then
start_zdaemon
echo "Zope started."
else
if [ $zdaemon -eq 1 ] && [ $zope -eq 1 ]; then
echo "Restarting zope process (old pid $zope_pid)."
stop_zope
else
echo "Zope currently restarting or something strange."
fi
fi
;;
*)
echo "Usage: $0 (start|stop|restart|status)"
;;
esac
--k1lZvvs/B4yU6o8G
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=zope
#! /bin/sh
#
# zope Start Zope.
#
NAME=zope
PATH=/bin:/usr/bin:/sbin:/usr/sbin
ZOPECTL=/usr/sbin/zopectl
#trap "" 1
#trap "" 15
test -f $ZOPECTL || exit 0
case "$1" in
start)
echo -n "Starting Zope: $NAME"
if $ZOPECTL start > /dev/null 2>&1
then
echo "."
else
echo "... failed."
fi
;;
stop)
echo -n "Stopping Zope: $NAME"
$ZOPECTL stop > /dev/null
echo "."
;;
restart)
echo -n "Restarting Zope: $NAME"
$ZOPECTL restart
echo "."
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|reload|reload-modules|force-reload|restart}"
exit 1
;;
esac
exit 0
--k1lZvvs/B4yU6o8G--