Commit 394d2e4a authored by Jim Fulton's avatar Jim Fulton

      - It is no longer necessary to symbolically link cPickle or
        ZServer. ZServer is no longer necessary at all.

      - A Zope-style INSTANCE_HOME and var directory are no longer
        needed.

      - If ZServer *is* available, the medusa monitor server can be
        used in the storage server.

      - An option, -d, was added to facilitate generation of a
        detailed debug log while running in the background.
parent 572b2b22
......@@ -86,7 +86,7 @@
"""Start the server storage.
"""
__version__ = "$Revision: 1.16 $"[11:-2]
__version__ = "$Revision: 1.17 $"[11:-2]
import sys, os, getopt, string
......@@ -130,17 +130,25 @@ def main(argv):
args.append(a)
last=a
INSTANCE_HOME=os.environ.get('INSTANCE_HOME', directory(me, 4))
if os.environ.has_key('INSTANCE_HOME'):
INSTANCE_HOME=os.environ['INSTANCE_HOME']
elif os.path.isdir(os.path.join(directory(me, 4),'var')):
INSTANCE_HOME=directory(me, 4)
else:
INSTANCE_HOME=os.getcwd()
if os.path.isdir(os.path.join(INSTANCE_HOME, 'var')):
var=os.path.join(INSTANCE_HOME, 'var')
else:
var=INSTANCE_HOME
zeo_pid=os.environ.get('ZEO_SERVER_PID',
os.path.join(INSTANCE_HOME, 'var', 'ZEO_SERVER.pid')
os.path.join(var, 'ZEO_SERVER.pid')
)
opts, args = getopt.getopt(args, 'p:Dh:U:sS:u:')
opts, args = getopt.getopt(args, 'p:Ddh:U:sS:u:')
fs=os.path.join(INSTANCE_HOME, 'var', 'Data.fs')
fs=os.path.join(var, 'Data.fs')
usage="""%s [options] [filename]
......@@ -148,6 +156,9 @@ def main(argv):
-D -- Run in debug mode
-d -- Generate detailed debug logging without running
in the foreground.
-U -- Unix-domain socket file to listen on
-u username or uid number
......@@ -182,7 +193,7 @@ def main(argv):
""" % (me, fs)
port=None
debug=0
debug=detailed=0
host=''
unix=None
Z=1
......@@ -193,12 +204,10 @@ def main(argv):
elif o=='-U': unix=v
elif o=='-u': UID=v
elif o=='-D': debug=1
elif o=='-d': detailed=1
elif o=='-s': Z=0
try:
from ZServer.medusa import asyncore
sys.modules['asyncore']=asyncore
except: pass
import fap # fixup asyncore/cPickle dependencies
if port is None and unix is None:
print usage
......@@ -212,9 +221,10 @@ def main(argv):
sys.exit(1)
fs=args[0]
__builtins__.__debug__=debug
if debug: os.environ['Z_DEBUG_MODE']='1'
if detailed: os.environ['STUPID_LOG_SEVERITY']='-99999'
from zLOG import LOG, INFO, ERROR
# Try to set uid to "-u" -provided uid.
......@@ -255,52 +265,67 @@ def main(argv):
import zdaemon
zdaemon.run(sys.argv, '')
import ZEO.StorageServer, asyncore
storages={}
for o, v in opts:
if o=='-S':
n, m = string.split(v,'=')
if string.find(m,':'):
# we got an attribute name
m, a = string.split(m,':')
else:
# attribute name must be same as storage name
a=n
storages[n]=get_storage(m,a)
if not storages:
import ZODB.FileStorage
storages['1']=ZODB.FileStorage.FileStorage(fs)
# Try to set up a signal handler
try:
import signal
signal.signal(signal.SIGTERM,
lambda sig, frame, s=storages: shutdown(s)
)
signal.signal(signal.SIGINT,
lambda sig, frame, s=storages: shutdown(s, 0)
)
signal.signal(signal.SIGHUP, rotate_logs_handler)
import ZEO.StorageServer, asyncore
storages={}
for o, v in opts:
if o=='-S':
n, m = string.split(v,'=')
if string.find(m,':'):
# we got an attribute name
m, a = string.split(m,':')
else:
# attribute name must be same as storage name
a=n
storages[n]=get_storage(m,a)
if not storages:
import ZODB.FileStorage
storages['1']=ZODB.FileStorage.FileStorage(fs)
# Try to set up a signal handler
try:
import signal
signal.signal(signal.SIGTERM,
lambda sig, frame, s=storages: shutdown(s)
)
signal.signal(signal.SIGINT,
lambda sig, frame, s=storages: shutdown(s, 0)
)
signal.signal(signal.SIGHUP, rotate_logs_handler)
finally: pass
finally: pass
items=storages.items()
items.sort()
for kv in items:
LOG('ZEO Server', INFO, 'Serving %s:\t%s' % kv)
items=storages.items()
items.sort()
for kv in items:
LOG('ZEO Server', INFO, 'Serving %s:\t%s' % kv)
if not unix: unix=host, port
if not unix: unix=host, port
ZEO.StorageServer.StorageServer(unix, storages)
ZEO.StorageServer.StorageServer(unix, storages)
open(zeo_pid,'w').write("%s %s" % (os.getppid(), os.getpid()))
asyncore.loop()
open(zeo_pid,'w').write("%s %s" % (os.getppid(), os.getpid()))
asyncore.loop()
except:
# Log startup exception and tell zdaemon not to restart us.
info=sys.exc_info()
try:
import zLOG
zLOG.LOG("z2", zLOG.PANIC, "Startup exception",
error=info)
except:
info2=sys.exc_info()
import traceback
traceback.print_exception(*info)
traceback.print_exception(*info2)
sys.exit(0)
def rotate_logs():
import zLOG
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment