[IMP] Added configuration option for gevent

bzr revid: nicolas.vanhoren@openerp.com-20121122145309-bim6m10p0q7rf6wj
This commit is contained in:
niv-openerp 2012-11-22 15:53:09 +01:00
parent 468652ccf7
commit 7137bb0b53
4 changed files with 19 additions and 13 deletions

View File

@ -224,15 +224,19 @@ def main():
check_root_user() check_root_user()
openerp.tools.config.parse_config(sys.argv[1:]) openerp.tools.config.parse_config(sys.argv[1:])
# TODO GEVENT if event if openerp.tools.config.options["gevent"]:
import gevent.monkey _logger.info('Using gevent mode')
gevent.monkey.patch_all() import gevent.monkey
import gevent_psycopg2 gevent.monkey.patch_all()
gevent_psycopg2.monkey_patch() import gevent_psycopg2
gevent_psycopg2.monkey_patch()
check_postgres_user() check_postgres_user()
openerp.netsvc.init_logger() openerp.netsvc.init_logger()
report_configuration() report_configuration()
if openerp.tools.config.options["gevent"]:
_logger.info('Using gevent mode')
config = openerp.tools.config config = openerp.tools.config

View File

@ -82,9 +82,9 @@ def start_services():
# Initialize the HTTP stack. # Initialize the HTTP stack.
netrpc_server.init_servers() netrpc_server.init_servers()
if openerp.conf.max_cron_threads: if not openerp.tools.config.options["gevent"]:
#openerp.cron.start_master_thread() if openerp.conf.max_cron_threads:
pass openerp.cron.start_master_thread()
# Start the top-level servers threads (normally HTTP, HTTPS, and NETRPC). # Start the top-level servers threads (normally HTTP, HTTPS, and NETRPC).
openerp.netsvc.Server.startAll() openerp.netsvc.Server.startAll()

View File

@ -424,10 +424,11 @@ def serve():
# TODO Change the xmlrpc_* options to http_* # TODO Change the xmlrpc_* options to http_*
interface = config['xmlrpc_interface'] or '0.0.0.0' interface = config['xmlrpc_interface'] or '0.0.0.0'
port = config['xmlrpc_port'] port = config['xmlrpc_port']
#httpd = werkzeug.serving.make_server(interface, port, application, threaded=True) if not openerp.tools.config.options["gevent"]:
# TODO GEVENT if event httpd = werkzeug.serving.make_server(interface, port, application, threaded=True)
from gevent.wsgi import WSGIServer else:
httpd = WSGIServer((interface, port), application) from gevent.wsgi import WSGIServer
httpd = WSGIServer((interface, port), application)
_logger.info('HTTP service (werkzeug) running on %s:%s', interface, port) _logger.info('HTTP service (werkzeug) running on %s:%s', interface, port)
httpd.serve_forever() httpd.serve_forever()

View File

@ -106,6 +106,7 @@ class configmanager(object):
help="specify additional addons paths (separated by commas).", help="specify additional addons paths (separated by commas).",
action="callback", callback=self._check_addons_path, nargs=1, type="string") action="callback", callback=self._check_addons_path, nargs=1, type="string")
group.add_option("--load", dest="server_wide_modules", help="Comma-separated list of server-wide modules default=web") group.add_option("--load", dest="server_wide_modules", help="Comma-separated list of server-wide modules default=web")
group.add_option("--gevent", dest="gevent", action="store_true", my_default=False, help="Activate the GEvent mode, this also desactivate the cron.")
parser.add_option_group(group) parser.add_option_group(group)
# XML-RPC / HTTP # XML-RPC / HTTP
@ -380,7 +381,7 @@ class configmanager(object):
'netrpc', 'xmlrpc', 'syslog', 'without_demo', 'timezone', 'netrpc', 'xmlrpc', 'syslog', 'without_demo', 'timezone',
'xmlrpcs_interface', 'xmlrpcs_port', 'xmlrpcs', 'xmlrpcs_interface', 'xmlrpcs_port', 'xmlrpcs',
'static_http_enable', 'static_http_document_root', 'static_http_url_prefix', 'static_http_enable', 'static_http_document_root', 'static_http_url_prefix',
'secure_cert_file', 'secure_pkey_file', 'dbfilter', 'log_handler', 'log_level' 'secure_cert_file', 'secure_pkey_file', 'dbfilter', 'log_handler', 'log_level', 'gevent'
] ]
for arg in keys: for arg in keys: