mirror of https://github.com/jumpserver/jumpserver
perf: 修正错误
parent
7a475fc029
commit
2bc47c87d1
|
@ -1,3 +1,4 @@
|
||||||
|
import multiprocessing
|
||||||
from django.core.management.base import BaseCommand, CommandError
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
from django.db.models import TextChoices
|
from django.db.models import TextChoices
|
||||||
from .utils import ServicesUtil
|
from .utils import ServicesUtil
|
||||||
|
@ -91,11 +92,15 @@ 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() + 1) < cores:
|
||||||
|
cores = multiprocessing.cpu_count() + 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=4)
|
parser.add_argument('-w', '--worker', type=int, nargs="?", default=cores)
|
||||||
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):
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import multiprocessing
|
|
||||||
from ..hands import *
|
from ..hands import *
|
||||||
from .base import BaseService
|
from .base import BaseService
|
||||||
|
|
||||||
|
@ -17,15 +16,12 @@ class GunicornService(BaseService):
|
||||||
|
|
||||||
log_format = '%(h)s %(t)s %(L)ss "%(r)s" %(s)s %(b)s '
|
log_format = '%(h)s %(t)s %(L)ss "%(r)s" %(s)s %(b)s '
|
||||||
bind = f'{HTTP_HOST}:{HTTP_PORT}'
|
bind = f'{HTTP_HOST}:{HTTP_PORT}'
|
||||||
cores = 10
|
|
||||||
if (multiprocessing.cpu_count() * 2 + 1) < cores:
|
|
||||||
cores = multiprocessing.cpu_count() * 2 + 1
|
|
||||||
|
|
||||||
cmd = [
|
cmd = [
|
||||||
'gunicorn', 'jumpserver.asgi:application',
|
'gunicorn', 'jumpserver.asgi:application',
|
||||||
'-b', bind,
|
'-b', bind,
|
||||||
'-k', 'uvicorn.workers.UvicornWorker',
|
'-k', 'uvicorn.workers.UvicornWorker',
|
||||||
'--threads', str(cores),
|
'--threads', str(self.worker * 2),
|
||||||
'-w', str(self.worker),
|
'-w', str(self.worker),
|
||||||
'--max-requests', '4096',
|
'--max-requests', '4096',
|
||||||
'--access-logformat', log_format,
|
'--access-logformat', log_format,
|
||||||
|
|
Loading…
Reference in New Issue