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

Fix neo log rotation

See merge request nexedi/erp5!1786
parents d496e223 c60d39e9
import six import six
import argparse import argparse
import atexit
from io import BytesIO from io import BytesIO
import logging import logging
import os import os
...@@ -176,6 +177,7 @@ def runwsgi(): ...@@ -176,6 +177,7 @@ def runwsgi():
parser.add_argument('zope_conf', help='path to zope.conf') parser.add_argument('zope_conf', help='path to zope.conf')
parser.add_argument('--timerserver-interval', help='Interval for timerserver', type=float) 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('--threads', help='Number of threads', default=4, type=int)
parser.add_argument('--pidfile', help='Write process id in file')
parser.add_argument( parser.add_argument(
'--large-file-threshold', '--large-file-threshold',
help='Requests bigger than this size in bytes get saved into a temporary file ' help='Requests bigger than this size in bytes get saved into a temporary file '
...@@ -184,13 +186,6 @@ def runwsgi(): ...@@ -184,13 +186,6 @@ def runwsgi():
default=type_registry.get('byte-size')("10MB")) default=type_registry.get('byte-size')("10MB"))
args = parser.parse_args() 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 # Configure logging previously handled by ZConfig/ZServer
logging.captureWarnings(True) logging.captureWarnings(True)
root_logger = logging.getLogger() root_logger = logging.getLogger()
...@@ -221,6 +216,18 @@ def runwsgi(): ...@@ -221,6 +216,18 @@ def runwsgi():
LongRequestLogger_dumper.logger.propagate = False LongRequestLogger_dumper.logger.propagate = False
LongRequestLogger_dumper.logger.addHandler(long_request_log_handler) 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: if conf.debug_mode:
console_handler = logging.StreamHandler(sys.stderr) console_handler = logging.StreamHandler(sys.stderr)
console_handler.setFormatter(logging.Formatter( 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