Commit b5e1ce4b authored by Jérome Perrin's avatar Jérome Perrin

zopwsgi neo

parent d496e223
import six
import argparse
import atexit
from io import BytesIO
import logging
import os
......@@ -176,6 +177,7 @@ def runwsgi():
parser.add_argument('zope_conf', help='path to zope.conf')
parser.add_argument('--timerserver-interval', help='Interval for timerserver', type=float)
parser.add_argument('--threads', help='Number of threads', default=4, type=int)
parser.add_argument('--pidfile', help='Write process id in file')
parser.add_argument(
'--large-file-threshold',
help='Requests bigger than this size in bytes get saved into a temporary file '
......@@ -184,13 +186,6 @@ def runwsgi():
default=type_registry.get('byte-size')("10MB"))
args = parser.parse_args()
startup = os.path.dirname(Zope2.Startup.__file__)
if os.path.isfile(os.path.join(startup, 'wsgischema.xml')):
schema = ZConfig.loadSchema(os.path.join(startup, 'wsgischema.xml'))
else: # BBB Zope2
schema = ZConfig.loadSchema(os.path.join(startup, 'zopeschema.xml'))
conf, _ = ZConfig.loadConfig(schema, args.zope_conf)
# Configure logging previously handled by ZConfig/ZServer
logging.captureWarnings(True)
root_logger = logging.getLogger()
......@@ -221,6 +216,18 @@ def runwsgi():
LongRequestLogger_dumper.logger.propagate = False
LongRequestLogger_dumper.logger.addHandler(long_request_log_handler)
if args.pidfile:
with open(args.pidfile, 'w') as f:
f.write('%s\n' % os.getpid())
atexit.register(os.unlink, args.pidfile)
startup = os.path.dirname(Zope2.Startup.__file__)
if os.path.isfile(os.path.join(startup, 'wsgischema.xml')):
schema = ZConfig.loadSchema(os.path.join(startup, 'wsgischema.xml'))
else: # BBB Zope2
schema = ZConfig.loadSchema(os.path.join(startup, 'zopeschema.xml'))
conf, _ = ZConfig.loadConfig(schema, args.zope_conf)
if conf.debug_mode:
console_handler = logging.StreamHandler(sys.stderr)
console_handler.setFormatter(logging.Formatter(
......
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