[FIX] do not expose posix only config options on windows
bzr revid: chs@openerp.com-20140306115214-8wrfivy4runpzoar
This commit is contained in:
parent
e4488138f7
commit
ec36a494fe
|
@ -9,7 +9,10 @@ import os.path
|
|||
import platform
|
||||
import psutil
|
||||
import random
|
||||
import resource
|
||||
if os.name == 'posix':
|
||||
import resource
|
||||
else:
|
||||
resource = None
|
||||
import select
|
||||
import signal
|
||||
import socket
|
||||
|
@ -638,6 +641,8 @@ class Worker(object):
|
|||
raise
|
||||
|
||||
def process_limit(self):
|
||||
if resource is None:
|
||||
return
|
||||
# If our parent changed sucide
|
||||
if self.ppid != os.getppid():
|
||||
_logger.info("Worker (%s) Parent changed", self.pid)
|
||||
|
|
|
@ -252,7 +252,8 @@ class configmanager(object):
|
|||
|
||||
# Advanced options
|
||||
group = optparse.OptionGroup(parser, "Advanced options")
|
||||
group.add_option('--auto-reload', dest='auto_reload', action='store_true', my_default=False, help='enable auto reload')
|
||||
if os.name == 'posix':
|
||||
group.add_option('--auto-reload', dest='auto_reload', action='store_true', my_default=False, help='enable auto reload')
|
||||
group.add_option('--debug', dest='debug_mode', action='store_true', my_default=False, help='enable debug mode')
|
||||
group.add_option("--stop-after-init", action="store_true", dest="stop_after_init", my_default=False,
|
||||
help="stop the server after its initialization")
|
||||
|
@ -274,27 +275,28 @@ class configmanager(object):
|
|||
help="Use the unaccent function provided by the database when available.")
|
||||
parser.add_option_group(group)
|
||||
|
||||
group = optparse.OptionGroup(parser, "Multiprocessing options")
|
||||
# TODO sensible default for the three following limits.
|
||||
group.add_option("--workers", dest="workers", my_default=0,
|
||||
help="Specify the number of workers, 0 disable prefork mode.",
|
||||
type="int")
|
||||
group.add_option("--limit-memory-soft", dest="limit_memory_soft", my_default=2048 * 1024 * 1024,
|
||||
help="Maximum allowed virtual memory per worker, when reached the worker be reset after the current request (default 671088640 aka 640MB).",
|
||||
type="int")
|
||||
group.add_option("--limit-memory-hard", dest="limit_memory_hard", my_default=2560 * 1024 * 1024,
|
||||
help="Maximum allowed virtual memory per worker, when reached, any memory allocation will fail (default 805306368 aka 768MB).",
|
||||
type="int")
|
||||
group.add_option("--limit-time-cpu", dest="limit_time_cpu", my_default=60,
|
||||
help="Maximum allowed CPU time per request (default 60).",
|
||||
type="int")
|
||||
group.add_option("--limit-time-real", dest="limit_time_real", my_default=120,
|
||||
help="Maximum allowed Real time per request (default 120).",
|
||||
type="int")
|
||||
group.add_option("--limit-request", dest="limit_request", my_default=8192,
|
||||
help="Maximum number of request to be processed per worker (default 8192).",
|
||||
type="int")
|
||||
parser.add_option_group(group)
|
||||
if os.name == 'posix':
|
||||
group = optparse.OptionGroup(parser, "Multiprocessing options")
|
||||
# TODO sensible default for the three following limits.
|
||||
group.add_option("--workers", dest="workers", my_default=0,
|
||||
help="Specify the number of workers, 0 disable prefork mode.",
|
||||
type="int")
|
||||
group.add_option("--limit-memory-soft", dest="limit_memory_soft", my_default=2048 * 1024 * 1024,
|
||||
help="Maximum allowed virtual memory per worker, when reached the worker be reset after the current request (default 671088640 aka 640MB).",
|
||||
type="int")
|
||||
group.add_option("--limit-memory-hard", dest="limit_memory_hard", my_default=2560 * 1024 * 1024,
|
||||
help="Maximum allowed virtual memory per worker, when reached, any memory allocation will fail (default 805306368 aka 768MB).",
|
||||
type="int")
|
||||
group.add_option("--limit-time-cpu", dest="limit_time_cpu", my_default=60,
|
||||
help="Maximum allowed CPU time per request (default 60).",
|
||||
type="int")
|
||||
group.add_option("--limit-time-real", dest="limit_time_real", my_default=120,
|
||||
help="Maximum allowed Real time per request (default 120).",
|
||||
type="int")
|
||||
group.add_option("--limit-request", dest="limit_request", my_default=8192,
|
||||
help="Maximum number of request to be processed per worker (default 8192).",
|
||||
type="int")
|
||||
parser.add_option_group(group)
|
||||
|
||||
# Copy all optparse options (i.e. MyOption) into self.options.
|
||||
for group in parser.option_groups:
|
||||
|
@ -405,12 +407,22 @@ class configmanager(object):
|
|||
'list_db', 'xmlrpcs', 'proxy_mode',
|
||||
'test_file', 'test_enable', 'test_commit', 'test_report_directory',
|
||||
'osv_memory_count_limit', 'osv_memory_age_limit', 'max_cron_threads', 'unaccent',
|
||||
'workers', 'limit_memory_hard', 'limit_memory_soft', 'limit_time_cpu', 'limit_time_real', 'limit_request',
|
||||
'auto_reload', 'data_dir',
|
||||
'data_dir',
|
||||
]
|
||||
|
||||
posix_keys = [
|
||||
'auto_reload', 'workers',
|
||||
'limit_memory_hard', 'limit_memory_soft',
|
||||
'limit_time_cpu', 'limit_time_real', 'limit_request',
|
||||
]
|
||||
|
||||
if os.name == 'posix':
|
||||
keys += posix_keys
|
||||
else:
|
||||
self.options.update(dict.fromkeys(posix_keys, None))
|
||||
|
||||
# Copy the command-line arguments...
|
||||
for arg in keys:
|
||||
# Copy the command-line argument...
|
||||
if getattr(opt, arg) is not None:
|
||||
self.options[arg] = getattr(opt, arg)
|
||||
# ... or keep, but cast, the config file value.
|
||||
|
|
Loading…
Reference in New Issue