I understand zdaemon is going away soon, but here's a small patch to
Daemon.py to fork if it finds an EVENT_LOG_FILE.

Also included is my start/stop scripts (for Unix), and a
custom_zodb.py which uses an environment variable ZODB_STORAGE to
determine what storage to use.  This allows me to use the same
codebase for my ZEO client Zopes and local FileStorage Zopes, simply
by changing a /etc/defaults style config file, also included.

The scripts in their current form may not be entirely suitable, but
they provide a point of departure for a slightly better startup
mechanism.

The non-detaching daemon, however, is just plain annoying.  On Unix
you can always tail the logfile for the same effect.

a.

-- 
 Adrian van den Dries                           [EMAIL PROTECTED]
 Development team                               www.dev.flow.com.au
 FLOW Communications Pty. Ltd.                  www.flow.com.au
--- Daemon.py.orig      2002-08-15 08:12:52.000000000 +1000
+++ Daemon.py   2003-01-20 15:59:45.000000000 +1100
@@ -29,7 +29,8 @@
 
     os.environ['ZDAEMON_MANAGED']='TRUE'
 
-    if not os.environ.has_key('Z_DEBUG_MODE'):
+    if not (os.environ.has_key('Z_DEBUG_MODE') and
+            not os.environ.has_key('EVENT_LOG_FILE')):
         detach() # detach from the controlling terminal
 
     while 1:

Attachment: config.sh
Description: Bourne shell script

#!/bin/sh

. $(dirname $0)/config.sh

export ZOPE_HOME SOFTWARE_HOME INSTANCE_HOME CLIENT_HOME ZODB_STORAGE
export EVENT_LOG_FILE EVENT_LOG_SEVERITY Z_DEBUG_MODE

cd $ZOPE_HOME

umask 077

if [ "$MONITOR_PORT" ]; then
    MONITOR="-m $MONITOR_PORT"
fi

if [ "$WEBDAV_PORT" ]; then
    WEBDAV="-W $WEBDAV_PORT"
fi

if [ "$HTTP_PORT" ]; then
    HTTP="-w $HTTP_PORT"
fi

if [ "$FTP_PORT" ]; then
    FTP="-f $FTP_PORT"
fi

exec python2.1 $ZOPE_HOME/z2.py -X $HTTP $FTP $WEBDAV $MONITOR "$@"
#! /bin/sh

. $(dirname $0)/config.sh

kill $(cat $ZOPE_HOME/var/Z2.pid)
import os

ZODB_STORAGE = os.environ.get('ZODB_STORAGE', '')
if not ZODB_STORAGE:
    raise "NoStorageInEnvironmentError"

try:
    stg = eval(ZODB_STORAGE)
except:
    stg = ZODB_STORAGE

if type(stg) is type(''):
    from ZODB.FileStorage import FileStorage
    Storage = FileStorage(stg)
else:
    from ZEO.ClientStorage import ClientStorage
    Storage = ClientStorage(stg, name='ZEO server on %s' % stg[0])

Reply via email to