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
#!/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
chkconfig line missing the "3"
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"
Thanks for the feedback,
Barry.
Order of stop/start
Cheers,
Barry
Re: Order
Clients 'should' go down before stopping Zeo.
:)
Order
Apapted for Ubuntu 6.06 LTS 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
Works for me on Ubuntu and 2.5.3
#!/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
configuration for buildout-version (plone3 zeo-cluster)
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
Run update-rc.d
http://www.debian-administration.org/articles/28
Works with CentOS 4.4