Merge pull request #11018 from jumpserver/pr@dev@perf_coreworker

perf: 优化 Core Worker 数量
pull/11019/head
老广 1 year ago committed by GitHub
commit 947c9e6216
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -94,15 +94,11 @@ class BaseActionCommand(BaseCommand):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
def add_arguments(self, parser): def add_arguments(self, parser):
cores = 10
if (multiprocessing.cpu_count() * 2 + 1) < cores:
cores = multiprocessing.cpu_count() * 2 + 1
parser.add_argument( parser.add_argument(
'services', nargs='+', choices=Services.export_services_values(), help='Service', 'services', nargs='+', choices=Services.export_services_values(), help='Service',
) )
parser.add_argument('-d', '--daemon', nargs="?", const=True) parser.add_argument('-d', '--daemon', nargs="?", const=True)
parser.add_argument('-w', '--worker', type=int, nargs="?", default=cores) parser.add_argument('-w', '--worker', type=int, nargs="?", default=4)
parser.add_argument('-f', '--force', nargs="?", const=True) parser.add_argument('-f', '--force', nargs="?", const=True)
def initial_util(self, *args, **options): def initial_util(self, *args, **options):

8
jms

@ -152,10 +152,14 @@ def start_services():
start_args = [] start_args = []
if args.daemon: if args.daemon:
start_args.append('--daemon') start_args.append('--daemon')
if args.worker:
start_args.extend(['--worker', str(args.worker)])
if args.force: if args.force:
start_args.append('--force') start_args.append('--force')
if args.worker:
start_args.extend(['--worker', str(args.worker)])
else:
worker = os.environ.get('CORE_WORKER')
if isinstance(worker, str) and worker.isdigit():
start_args.extend(['--worker', worker])
try: try:
management.call_command(action, *services, *start_args) management.call_command(action, *services, *start_args)

Loading…
Cancel
Save