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