[Pkg-zope-developers] ZEO woes

Igor Stroh igor at rulim.de
Fri Jul 22 21:37:03 UTC 2005


Hi all!

Yesterday I updated zope2.7 on some of my productive servers and forgot to
backup my custom /etc/init.d/zope2.7, so it was overwritten. That did hurt
a bit, but also it made me reconsider the way I created ZEO instances:
I placed my ZEOs under /var/lib/zeo2.7, that's why the were not started by
the new init script, my fault anyway...

I checked the new zope2.7 init script and realized that it already tries
to start a ZEO server if it's in $INSTANCES, however the script does
not take into account that one of the Zope instances may rely on a ZEO
instance. So if you just go ahead and start everything found in
/var/lib/zope2.7/instance, you might end up with a broken ZEO
connection in Zope ("Client disconnected").

Now I hacked a quick workaround [see attachment], maybe it's worth
including it into the package...

Cheers,
Igor
-------------- next part --------------
#!/bin/sh
# -----------------------------------------------------------------------------
# First coded by Luca - De Whiskey's - De Vitis <luca at debian.org>
# -----------------------------------------------------------------------------
# $Id: zope.init,v 1.6 2003/09/26 21:10:39 luca Exp $
#
#   Copyright (C) 2003 Luca - De Whiskey's - De Vitis <luca at debian.org>
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

PATH=/bin:/usr/bin:/sbin:/usr/sbin

case "$1" in
    start|stop|restart|force-reload) ;; #later
    *)
        # (Igor Stroh) there's no force-reload in zopectl/zeoctl
        #echo "Usage: $0 {start|stop|restart|force-reload}"
        echo "Usage: $0 {start|stop|restart}"
        exit 1
    ;;
esac

zope=zope2.7

D=/var/lib/$zope/instance

[ -d $D -a -d /usr/lib/$zope ] || exit 0

. /etc/default/$zope

cd $D

p=''; [ "$1" = "stop" ] && p='p'

if [ "$INSTANCES" = "NONE" -o  "$INSTANCES" = "" ]; then
        echo "$0 does not $1 any instance - edit /etc/default/$zope to enable automatic $1${p}ing of instances ."
        exit 0
elif [ "$INSTANCES" = ALL ]; then
      INSTANCES=$(echo *)
fi
if [ "$INSTANCES" = '*' ]; then    
    if [ "$1" != stop ] ; then
	echo "There are currently no $zope instances in $D . To create them, use mk${zope}instance "
    fi
    exit 0
fi

### (Igor Stroh) workaround that ensures zeos and zopes are
### started in the right order
# $1: instance home
# $2: zope|zeo
# $3: action
do_action() {
    instance=$1
    what=$2
    action=$3
    ctlpath=$instance"/bin/"$what"ctl"
    if [ -x $ctlpath ] ; then
        echo -n $ctlpath "$action"
        $ctlpath "$action"
        echo
    fi
}

start_instances() {
    for instance in $INSTANCES ; do
        do_action $instance zeo start
    done
    for instance in $INSTANCES ; do
        do_action $instance zope start
    done
}

stop_instances() {
    for instance in $INSTANCES ; do
        do_action $instance zope stop
    done
    for instance in $INSTANCES ; do
        do_action $instance zeo stop
    done
}

restart_instances() {
    stop_instances
    start_instances
}

echo Zope ${1}${p}ing all instances...
[ "$1" = "stop" ] && stop_instances
[ "$1" = "start" ] && start_instances
[ "$1" = "restart" ] && restart_instances
exit 0


More information about the Pkg-zope-developers mailing list