Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
erp5
Commits
9f9294a8
Commit
9f9294a8
authored
Mar 06, 2023
by
Levin Zimmermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
483dc85d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
8 deletions
+57
-8
product/ERP5/bin/zopewsgitw.py
product/ERP5/bin/zopewsgitw.py
+57
-8
No files found.
product/ERP5/bin/zopewsgitw.py
View file @
9f9294a8
...
...
@@ -81,6 +81,8 @@ class TransLogger(object):
def
app_wrapper
(
large_file_threshold
=
10
<<
20
,
webdav_ports
=
()):
if
large_file_threshold
is
None
:
large_file_threshold
=
10
<<
20
try
:
from
Products.DeadlockDebugger.dumper
import
dump_threads
,
dump_url
except
Exception
:
...
...
@@ -242,8 +244,6 @@ def runwsgi():
ident
=
None
,
).
run
()
server
=
None
################################################################
#
# Please read the code below.
...
...
@@ -257,11 +257,15 @@ from twisted.web.wsgi import WSGIResource
from
twisted.internet
import
protocol
,
reactor
,
endpoints
from
twisted.web
import
server
as
twisted_server
from
io
import
StringIO
import
urllib
# I modified runwsgi() without thinking carefully.
# Very dirty code.
def
runwsgitw
():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--event-log-file'
,
help
=
'Event log file'
)
parser
.
add_argument
(
'--access-log-file'
,
help
=
'Access log file'
)
parser
.
add_argument
(
'--long-request-log-file'
,
help
=
'Long requests log file'
)
parser
.
add_argument
(
'-w'
,
'--webdav'
,
action
=
'store_true'
)
parser
.
add_argument
(
'address'
,
help
=
'<ip>:<port>'
)
parser
.
add_argument
(
'zope_conf'
,
help
=
'path to zope.conf'
)
...
...
@@ -269,9 +273,50 @@ def runwsgitw():
args
=
parser
.
parse_args
()
startup
=
os
.
path
.
dirname
(
Zope2
.
Startup
.
__file__
)
schema
=
ZConfig
.
loadSchema
(
os
.
path
.
join
(
startup
,
'zopeschema.xml'
))
if
os
.
path
.
isfile
(
os
.
path
.
join
(
startup
,
'wsgischema.xml'
)):
schema
=
ZConfig
.
loadSchema
(
os
.
path
.
join
(
startup
,
'wsgischema.xml'
))
else
:
# BBB
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
()
root_logger
.
setLevel
(
logging
.
INFO
)
if
args
.
event_log_file
is
None
:
event_log_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
else
:
event_log_handler
=
logging
.
FileHandler
(
args
.
event_log_file
)
event_log_handler
.
setFormatter
(
logging
.
Formatter
(
"------
\
n
%(asctime)s,%(msecs)d %(levelname)s %(name)s %(message)s"
,
"%Y-%m-%d %H:%M:%S"
))
root_logger
.
addHandler
(
event_log_handler
)
if
args
.
access_log_file
is
None
:
access_log_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
else
:
access_log_handler
=
logging
.
FileHandler
(
args
.
access_log_file
)
access_log_handler
.
setLevel
(
logging
.
INFO
)
access_log_logger
=
logging
.
getLogger
(
'access'
)
access_log_logger
.
propagate
=
False
access_log_logger
.
addHandler
(
access_log_handler
)
if
args
.
long_request_log_file
:
from
Products.ERP5Type.patches
import
LongRequestLogger_dumper
long_request_log_handler
=
logging
.
FileHandler
(
args
.
long_request_log_file
)
long_request_log_handler
.
setFormatter
(
logging
.
Formatter
(
"%(asctime)s - %(message)s"
))
LongRequestLogger_dumper
.
logger
.
propagate
=
False
LongRequestLogger_dumper
.
logger
.
addHandler
(
long_request_log_handler
)
if
conf
.
debug_mode
:
console_handler
=
logging
.
StreamHandler
(
sys
.
stderr
)
console_handler
.
setFormatter
(
logging
.
Formatter
(
"%(asctime)s,%(msecs)d %(levelname)s %(name)s %(message)s"
,
"%Y-%m-%d %H:%M:%S"
))
console_handler
.
setLevel
(
logging
.
NOTSET
)
root_logger
.
addHandler
(
console_handler
)
make_wsgi_app
({},
zope_conf
=
args
.
zope_conf
)
if
six
.
PY2
:
...
...
@@ -293,17 +338,21 @@ def runwsgitw():
# Let's add Twisted. I do not use waitress.
#
#################################################
ip
,
port
=
splitport
(
args
.
address
)
ip
,
port
=
urllib
.
parse
.
splitport
(
args
.
address
)
port
=
int
(
port
)
# Keep ERP5 original implementation.
# This is ERP5 wsgi interface, it means that this is
# the entrance of ERP5.
translogger
=
TransLogger
(
app_wrapper
(
large_file_threshold
=
conf
.
large_file_threshold
,
webdav_ports
=
[
port
]
if
args
.
webdav
else
()),
logger
=
logging
.
getLogger
(
"access"
))
app_wrapper
(
large_file_threshold
=
getattr
(
conf
,
'large_file_threshold'
,
None
),
webdav_ports
=
[
int
(
args
.
address
.
rsplit
(
':'
,
1
)[
1
])]
if
args
.
webdav
else
()
),
logger
=
access_log_logger
,
# threads=getattr(conf, 'zserver_threads', 4)
# listen=args.address,
)
# Let's use twisted's wsgi wrapper.
resource
=
WSGIResource
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment