Personal tools
You are here: Home Documentation How-tos Simple /etc/rc.d/init.d script for Zeocluster
Support

Get Help

Join our chat rooms or support forums if you have more specific questions.

Plone Training
Learn how to design, build, and deploy a website in Plone through one of the numerous Plone training sessions around the world.
Find Plone training…
 
Document Actions

Simple /etc/rc.d/init.d script for Zeocluster

This How-to applies to: Plone 2.5.x
This How-to is intended for: Server Administrators

I tested this on Fedora Core 5 and the default "Universal" Linux installer for Plone 2.5.1. I think this is a useful script to start zeo/zope rather than using the startcluster etc command line scripts
Suggestions for improvement are welcome. This is the first time I have written an init.d script
#!/bin/sh
# /etc/rc.d/init.d/zeo
# Startup script for Zope with ZEOCluster
#
# chkconfig: 345 80 20
# description: Zope, a web application server
# this works as is for a default universal plone linux install
#
# config: /opt/Plone-2.5/zeocluster/client$/etc/zope.conf
# Source function library.
. /etc/init.d/functions

RETVAL=0
# list zeo clients in the list below
zeoclients="client1 client2"
# this is for the default install path for 2.5.1
clusterpath="/opt/Plone-2.5/zeocluster"
prog="ZEOCluster"

start() {
echo -n $"Starting $prog: "
    output=`${clusterpath}/server/bin/zeoctl start`
   # the return status of zopectl is not reliable, we need to parse
    # its output via substring match
    if echo $output | grep -q "start"; then
            # success
            touch /var/lock/subsys/$prog
            success
            echo
            RETVAL=0
    else
            # failed
            failure
            echo
            RETVAL=1
    fi
for client in $zeoclients
    do
         echo -n $"Starting $client: "
    output=`${clusterpath}/${client}/bin/zopectl start`
        # the return status of zopectl is not reliable, we need to parse
        # its output via substring match
        if echo $output | grep -q "start"; then
            # success
            touch /var/lock/subsys/zope${client}
            success
            echo
            RETVAL=0
        else
            # failed
            failure
            echo
            RETVAL=1
        fi
    done
        return $RETVAL
}

stop() {

for client in $zeoclients
    do
       echo -n $"Stopping $client: "
    output=`${clusterpath}/${client}/bin/zopectl stop`
       # the return status of zopectl is not reliable, we need to parse
        # its output via substring match
        if echo $output | grep -q "stop"; then
            # success
           rm /var/lock/subsys/zope${client}
            success
            echo
            RETVAL=0
        else
            # failed
            failure
            echo
            RETVAL=1
        fi
    done
    echo -n $"Stopping $prog: "
    output=`${clusterpath}/server/bin/zeoctl stop`
    # the return status of zopectl is not reliable, we need to parse
    # its output via substring match
    if echo $output | grep -q "stop"; then
            # success
            rm /var/lock/subsys/$prog
            success
            echo
            RETVAL=0
    else
            # failed
            failure
            echo
            RETVAL=1
    fi
        return $RETVAL
}

restart() {
   stop
   start
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
status)
echo "ZEO Server:"
output=`${clusterpath}/server/bin/zeoctl status`
echo $output
for client in $zeoclients
do
echo "Zope Client" $client
output=`${clusterpath}/${client}/bin/zopectl status`
echo $output
done
;;
  restart)
    restart
    ;;
  condrestart)
    [ -e /var/lock/subsys/$prog ] && restart
    ;;
  *)
    echo $"Usage: $0 {start|stop|status|restart|condrestart}"
    RETVAL=2
esac

exit $RETVAL
by Barry Page last modified December 13, 2006 - 08:16 All content is copyright Plone Foundation and the individual contributors.

Works with CentOS 4.4

Posted by Frank Jones at December 2, 2006 - 18:08
Seems to work fine with CentOS 4.4 and Plone 2.5.1. Thanks.

chkconfig line missing the "3"

Posted by Larry Pitcher at December 5, 2006 - 00:37
Barry,

Not to be picky, but I think the chkconfig line should read:

# chkconfig: 345 80 20

This way if we turn the service on using "chkconfig zope on" it will start in runlevel 3, which I usually use, especially on old, slow boxes.

Thanks,

Larry Pitcher

Re: chkconfig line missing the "3"

Posted by Barry Page at December 5, 2006 - 02:08
Suitably amended.
Thanks for the feedback,
Barry.

Order of stop/start

Posted by Barry Page at December 5, 2006 - 02:12
Does anyone think it matters that we are starting AND stopping in the order zeoserver->client1->client2 ? (I haven't had any issues with that, but then I don't have a high transaction/ busy site)
Cheers,
Barry

Re: Order

Posted by Darryl Dixon at December 13, 2006 - 03:37
Zeo 'should' come up before starting clients.
Clients 'should' go down before stopping Zeo.

:)

Order

Posted by Barry Page at December 13, 2006 - 08:17
That makes sense --- I've changed the 'stop' order. Thanks for your input!

Apapted for Ubuntu 6.06 LTS and Plone 2.5.2

Posted by Christian W. at April 15, 2007 - 22:37
I adapted and tested the script for Ubuntu Dapper and Plone 2.5.2:
<pre>
#!/bin/sh
# /etc/init.d/zeo
# Startup script for Zope/Plone with ZEOCluster
#
# adapted for Ubuntu paths, 2.5.2 version and LSB functions
#
# chkconfig: 345 80 20
# description: Zope, a web application server
# this works as is for a default universal plone linux install
#
# config: /opt/Plone-2.5.2/zeocluster/client$/etc/zope.conf
# LSB Source function library
. /lib/lsb/init-functions

RETVAL=0
# list zeo clients in the list below
zeoclients="client1 client2"

# this is for the default install path for 2.5.2
clusterpath="/opt/Plone-2.5.2/zeocluster"
prog="ZEOCluster"

start() {
echo -n $"Starting $prog: "
output=`${clusterpath}/server/bin/zeoctl start`
# the return status of zopectl is not reliable, we need to parse
# its output via substring match
if echo $output | grep -q "start"; then
# success
touch /var/lock/$prog
log_success_msg "zeo started successfully"
echo
RETVAL=0
else
# failed
log_failure_msg "zeo failed to start or was already started"
echo
RETVAL=1
fi
for client in $zeoclients
do
echo -n $"Starting $client: "
output=`${clusterpath}/${client}/bin/zopectl start`
# the return status of zopectl is not reliable, we need to parse
# its output via substring match
if echo $output | grep -q "start"; then
# success
touch /var/lock/zope${client}
log_success_msg "$client started successfully"
echo
RETVAL=0
else
# failed
log_failure_msg "$client failed to start or was already started"
echo
RETVAL=1
fi
done
return $RETVAL
}

stop() {

for client in $zeoclients
do
echo -n $"Stopping $client: "
output=`${clusterpath}/${client}/bin/zopectl stop`
# the return status of zopectl is not reliable, we need to parse
# its output via substring match
if echo $output | grep -q "stop"; then
# success
rm /var/lock/zope${client}
log_success_msg "$client stopped successfully"
echo
RETVAL=0
else
# failed
log_failure_msg "$client failed to stop or was already stopped"
echo
RETVAL=1
fi
done
echo -n $"Stopping $prog: "
output=`${clusterpath}/server/bin/zeoctl stop`
# the return status of zopectl is not reliable, we need to parse
# its output via substring match
if echo $output | grep -q "stop"; then
# success
rm /var/lock/$prog
log_success_msg "zeo stopped successfully"
echo
RETVAL=0
else
# failed
log_failure_msg "zeo failed to stop or was already stopped"
echo
RETVAL=1
fi
return $RETVAL
}

restart() {
stop
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
status)
echo "ZEO Server:"
output=`${clusterpath}/server/bin/zeoctl status`
echo $output
for client in $zeoclients
do
echo "Zope Client" $client
output=`${clusterpath}/${client}/bin/zopectl status`
echo $output
done
;;
restart)
restart
;;
condrestart)
[ -e /var/lock/$prog ] && restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
RETVAL=2
esac

exit $RETVAL
</pre>

Hmmm, the formatting disappeared

Posted by Christian W. at April 15, 2007 - 23:14
I almost expected that the pre tags would be filtered, but even all the leading spaces are gone. It would be nice to have some formatting preserved in comments. I hope the post might still be useful.

Works for me on Ubuntu and 2.5.3

Posted by Michael at September 15, 2007 - 05:33
Used it as it was, but removed the extra $'s in front of "Starting" and "Stopping" and changed 2.5.2 to 2.5.3. Here a try at keeping it with some formatting::

#!/bin/sh
# /etc/init.d/zeo
# Startup script for Zope/Plone with ZEOCluster
#
# adapted for Ubuntu paths, 2.5.3 version and LSB functions
#
# chkconfig: 345 80 20
# description: Zope, a web application server
# this works as is for a default universal plone linux install
#
# config: /opt/Plone-2.5.3/zeocluster/client$/etc/zope.conf
# LSB Source function library
. /lib/lsb/init-functions

RETVAL=0
# list zeo clients in the list below
zeoclients="client1 client2"

# this is for the default install path for 2.5.3
clusterpath="/opt/Plone-2.5.3/zeocluster"
prog="ZEOCluster"

start() {
echo -n "Starting $prog: "
output=`${clusterpath}/server/bin/zeoctl start`

# the return status of zopectl is not reliable, we need to parse
# its output via substring match
if echo $output | grep -q "start"; then
# success
touch /var/lock/$prog
log_success_msg "zeo started successfully"
echo
RETVAL=0
else
# failed
log_failure_msg "zeo failed to start or was already started"
echo
RETVAL=1
fi

for client in $zeoclients
do
echo -n "Starting $client: "
output=`${clusterpath}/${client}/bin/zopectl start`

# the return status of zopectl is not reliable, we need to parse
# its output via substring match
if echo $output | grep -q "start"; then
# success
touch /var/lock/zope${client}
log_success_msg "$client started successfully"
echo
RETVAL=0
else
# failed
log_failure_msg "$client failed to start or was already started"
echo
RETVAL=1
fi
done

return $RETVAL
}

stop() {

for client in $zeoclients
do
echo -n "Stopping $client: "
output=`${clusterpath}/${client}/bin/zopectl stop`

# the return status of zopectl is not reliable, we need to parse
# its output via substring match
if echo $output | grep -q "stop"; then
# success
rm /var/lock/zope${client}
log_success_msg "$client stopped successfully"
echo
RETVAL=0
else
# failed
log_failure_msg "$client failed to stop or was already stopped"
echo
RETVAL=1
fi
done

echo -n "Stopping $prog: "
output=`${clusterpath}/server/bin/zeoctl stop`

# the return status of zopectl is not reliable, we need to parse
# its output via substring match
if echo $output | grep -q "stop"; then
# success
rm /var/lock/$prog
log_success_msg "zeo stopped successfully"
echo
RETVAL=0
else
# failed
log_failure_msg "zeo failed to stop or was already stopped"
echo
RETVAL=1
fi

return $RETVAL
}

restart() {
stop
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
status)
echo "ZEO Server:"
output=`${clusterpath}/server/bin/zeoctl status`
echo $output
for client in $zeoclients
do
echo "Zope Client" $client
output=`${clusterpath}/${client}/bin/zopectl status`
echo $output
done
;;
restart)
restart
;;
condrestart)
[ -e /var/lock/$prog ] && restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
RETVAL=2
esac

exit $RETVAL

No luck with the formatting

Posted by Michael at September 15, 2007 - 05:39
All those nice tabs ...

configuration for buildout-version (plone3 zeo-cluster)

Posted by Florian Lagg at May 15, 2008 - 13:11
That's my configuration I used in my buildout-environment.
It's for plone3

I think buildout should generate an ready-to-use script somewhere - does anyone know how to implement this?
Not a such easy task because it has to take care of various configuration options, from a single instance to a zeo-cluster.

#!/bin/sh
# /etc/rc.d/init.d/zeo
# Startup script for Zope with ZEOCluster
#
# chkconfig: 345 80 20
# description: Zope, a web application server
# this works as is for a default universal plone linux install
#
# Source function library.
# config: /opt/plone3/parts/client$/etc/zope.conf
. /lib/lsb/init-functions

RETVAL=0
# list zeo clients in the list below
zeoclients="client1 client2"
# this is for the default install path for 3.x
clusterpath="/opt/plone3/parts"
prog="ZEOCluster"

start() {
echo -n $"Starting $prog: "
output=`${clusterpath}/zeoserver/bin/zeoctl start`
# the return status of zopectl is not reliable, we need to parse
# its output via substring match
if echo $output | grep -q "start"; then
# success
touch /var/lock/$prog
log_success_msg "$prog started successfully"
echo
RETVAL=0
else
# failed
log_failure_msg "$prog failed to start or was already started"
echo
RETVAL=1
fi
for client in $zeoclients
do
echo -n $"Starting $client: "
output=`${clusterpath}/${client}/bin/zopectl start`
# the return status of zopectl is not reliable, we need to parse
# its output via substring match
if echo $output | grep -q "start"; then
# success
touch /var/lock/zope${client}
log_success_msg "$prog: $client started successfully"
echo
RETVAL=0
else
# failed
log_failure_msg "$prog: $client failed to start or was already started"
echo
RETVAL=1
fi
done
return $RETVAL
}

stop() {

for client in $zeoclients
do
echo -n $"Stopping $client: "
output=`${clusterpath}/${client}/bin/zopectl stop`
# the return status of zopectl is not reliable, we need to parse
# its output via substring match
if echo $output | grep -q "stop"; then
# success
rm /var/lock/zope${client}
log_success_msg "$prog: $client stopped successfully"
echo
RETVAL=0
else
# failed
log_failure_msg "$prog: $client failed to stop or was already stopped"
echo
RETVAL=1
fi
done
echo -n $"Stopping $prog: "
output=`${clusterpath}/zeoserver/bin/zeoctl stop`
# the return status of zopectl is not reliable, we need to parse
# its output via substring match
if echo $output | grep -q "stop"; then
# success
rm /var/lock/$prog
log_success_msg "$prog stopped successfully"
echo
RETVAL=0
else
# failed
log_failure_msg "$prog failed to stop or was already stopped"
echo
RETVAL=1
fi
return $RETVAL
}

restart() {
stop
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
status)
echo "ZEO Server:"
output=`${clusterpath}/zeoserver/bin/zeoctl status`
echo $output
for client in $zeoclients
do
echo "Zope Client" $client
output=`${clusterpath}/${client}/bin/zopectl status`
echo $output
done
;;
restart)
restart
;;
condrestart)
[ -e /var/lock/$prog ] && restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
RETVAL=2
esac

exit $RETVAL

tabs/spaces

Posted by Florian Lagg at May 15, 2008 - 13:14
May we have a formatting editor here? *gg*

Run update-rc.d

Posted by Mikko Ohtamaa at June 19, 2008 - 08:43
On Debian you must remember to run update-rc.d command or /etc/init.d changes don't become effective.

http://www.debian-administration.org/articles/28

For any issues with the web site functionality, please file a ticket.

Please consult the policy on plone.org content if you want your content published on this site.

Servers and hosting by