If you're a newbie like me, running a single instance of Zope on Red Hat Linux, you may want Zope to start up automatically at boot. Here's an init script I wrote that might help. Put this script in your /etc/rc.d/init.d directory, name it 'zope', and 'chmod +x zope'. Then use chkconfig or the GUI Service Configurator to turn the script on for the run-levels you want (see link in script for more about run-levels). Typically, you'll want to turn on levels 3, 4, and 5. The point of this script is to - as much as I could - start up and shut down Zope like other Linux services, e.g. crond or sshd. Read the comments in the script for more info. NOTE: This script was written to start Zope as a regular user (non-root), so I don't think you can set the HTTP port to 80, for instance. (My intention is to set up Squid on that port to cache and relay Zope pages.) Hope this helps, Jon Whitener Detroit, Michigan, USA ----- SCRIPT BEGINS BELOW ------ #!/bin/bash # # /etc/rc.d/init.d/zope # # SysV init script for the Zope web application server; # written for Red Hat Linux 7.3. # # chkconfig: 345 60 40 # processname: zope # pidfile: /var/run/zope.pid # description: The Zope Web application server provides an \ # on-line infrastructure for developing and serving \ # Web sites. # Red Hat (I'm using version 7.3) provides standard functions for System V # init scripts that start and stop services listed in the rc.? directories # (when changing run-levels, like at boot-time), as well as other functions # like status and restart. # # Unfortunately, these functions (found in /etc/init.d/functions) have a # weakness when it comes to monitoring Zope: they rely on reading a 'pid # file' for Zope in the /var/run directory to determine whether or not Zope # is running. (A 'pid file' is simply a small text file containing the # process ID number of the service.) # # Zope writes its pid file to /zope-dir/var/Z2.pid when it starts, and # furthermore, Zope does not remove the pid file when Zope shuts down. # # So, I've tried to implement the intent of the daemon (start), killproc # (stop), status, and reload/restart functions here for Zope, using as much # as possible of the Red Hat functions, which for one thing makes it easy # to start Zope at boot-time as a non-super user ********* # # One thing I didn't solve was removing the /var/run/ pid file when Zope # is shut down without using the killproc function, e.g. when it is # shut down through-the-web via the Zope control panel. The main # effect of this is that you'll see a (harmless) [FAILED] indicator # when Linux tries to shut down a process that isn't running. # # For more information on Red Hat runlevels, see: # http://www.redhat.com/support/resources/tips/Boot-Process-Tips/Boot-Process-... # # Note that this script is intended for a single Zope instance. # # Jon Whitener # 11 November 2002 # Source function library. (This imports the standard SysV # Red Hat functions that this script uses.) . /etc/rc.d/init.d/functions # Here you customize the directory location to fit your # Zope installation. ZOPE_DIR="/zope" # The following two lines won't typically need changing. ZOPE="$ZOPE_DIR/z2.py" ZPYTHON="$ZOPE_DIR/bin/python" # You need to add the name of the user who # you want to run Zope here: ZOPE_USER=zopefella # Add the options to pass to z2.py when running Zope below. # Run $ZOPE_DIR/bin/python $ZOPE_DIR/z2.py --help for more info. # I removed the -D debug mode default, and set an event log. OPTIONS="EVENT_LOG_FILE=$ZOPE_DIR/var/event.log" RETVAL=0 zope_pid() { # Look for a Zope process ID in a pid file. local ZPID= if [ -f "/var/run/zope.pid" ] ; then ZPID=`cat /var/run/zope.pid` else [ -f "$ZOPE_DIR/var/Z2.pid" ] && ZPID=`cat $ZOPE_DIR/var/Z2.pid` fi echo $ZPID return 0 } zope_daemon() { # Process parameters, check if Zope is already running, and either # start it or don't. Some of this copied from original daemon function. local user= local base=zope local ZPID= local RUNNING= nicelevel=0 while [ "$1" != "${1##[-+]}" ]; do case $1 in '') echo $"$0: Usage: daemon [+/-nicelevel] {program}" return 1;; --user) user=$2 shift 2 ;; --user=?*) user=${1#--user=} shift ;; *) echo $"$0: Usage: daemon [+/-nicelevel] {program}" return 1;; esac done # See if Zope is already running. This is where we really start # to differ from the standard daemon function in # /etc/init.d/functions ZPID=`zope_pid` # If pid number matches a running zope process, skip start-up. local OK_TO_START=0 if [ -z "$ZPID" ] ; then # No Zope pid file found. Probably OK to start Zope. OK_TO_START=1 else # Check if $ZPID matches a running Zope (z2.py) process. RUNNING=`ps -p "$ZPID" -o cmd | grep "z2.py"` # If $RUNNING is not null, then Zope is already running. # If $RUNNING is null, then pid file exists, but Zope is dead. [ -z "$RUNNING" ] && OK_TO_START=1 fi if [ $OK_TO_START -eq 1 ] ; then # make sure it doesn't core dump anywhere; while this could mask # problems with the daemon, it also closes some security problems ulimit -S -c 0 >/dev/null 2>&1 # Echo daemon [ "${BOOTUP:-}" = "verbose" -a -z "$LSB" ] && echo -n " $base" # And start it up. if [ -z "$user" ]; then $nice initlog $INITLOG_ARGS -c "$*" else $nice initlog $INITLOG_ARGS -c "su -s /bin/bash - $user -c \"$*\"" fi [ "$?" -eq 0 ] && success $"$base startup" || failure $"$base startup" fi return } start() { echo -n "Starting zope: " ln -sf $ZOPE_DIR/var/Z2.pid /var/run/zope.pid zope_daemon --user $ZOPE_USER $ZPYTHON $ZOPE $OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && ln -sf $ZOPE_DIR/var/Z2.pid /var/run/zope.pid return $RETVAL } stop() { echo -n "Shutting down zope: " killproc zope RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/run/zope.pid return $RETVAL } zope_status() { local ZPID= RUNNING= ZPID=`zope_pid` # Check if pid number matches a running process, and echo results. if [ -z "$ZPID" ] ; then echo "Zope is probably not running. Valid Zope pid file not found." else RUNNING=`ps -p "$ZPID" -o cmd | grep "z2.py"` if [ -z "$RUNNING" ] ; then echo "Zope dead, but pid file exists" else echo "Zope running with pid $ZPID" fi fi return 0 } case "$1" in start) start ;; stop) stop ;; status) zope_status ;; restart|reload) stop start ;; *) echo "Usage: zope {start|stop|status|reload|restart}" exit 1 ;; esac exit $?