From e1af380ad5e366c5cbe7faa92519d69a42db9d96 Mon Sep 17 00:00:00 2001 From: Bai Date: Wed, 19 Jul 2023 17:12:44 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=20Core=20Worker=20?= =?UTF-8?q?=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/management/commands/services/command.py | 6 +----- jms | 8 ++++++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/common/management/commands/services/command.py b/apps/common/management/commands/services/command.py index 6ec38ab2b..487d9ce5f 100644 --- a/apps/common/management/commands/services/command.py +++ b/apps/common/management/commands/services/command.py @@ -94,15 +94,11 @@ class BaseActionCommand(BaseCommand): super().__init__(*args, **kwargs) def add_arguments(self, parser): - cores = 10 - if (multiprocessing.cpu_count() * 2 + 1) < cores: - cores = multiprocessing.cpu_count() * 2 + 1 - parser.add_argument( 'services', nargs='+', choices=Services.export_services_values(), help='Service', ) 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) def initial_util(self, *args, **options): diff --git a/jms b/jms index c75011edd..0b2cf94d0 100755 --- a/jms +++ b/jms @@ -152,10 +152,14 @@ def start_services(): start_args = [] if args.daemon: start_args.append('--daemon') - if args.worker: - start_args.extend(['--worker', str(args.worker)]) if args.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: management.call_command(action, *services, *start_args)