diff --git a/apps/common/management/commands/celery.py b/apps/common/management/commands/celery.py index 95a21eb76..8b8e1b3e5 100644 --- a/apps/common/management/commands/celery.py +++ b/apps/common/management/commands/celery.py @@ -26,6 +26,8 @@ class Command(BaseCommand): service = options.get('service') os.environ.setdefault('CELERY_NAME', ','.join(service)) server_hostname = os.environ.get("SERVER_HOSTNAME") + if os.getuid() == 0: + os.environ.setdefault('C_FORCE_ROOT', '1') if not server_hostname: server_hostname = '%h' cmd = [ diff --git a/apps/common/management/commands/services/command.py b/apps/common/management/commands/services/command.py index 960d019ec..c5b719272 100644 --- a/apps/common/management/commands/services/command.py +++ b/apps/common/management/commands/services/command.py @@ -3,6 +3,7 @@ from django.db.models import TextChoices from .hands import * from .utils import ServicesUtil +import os class Services(TextChoices): @@ -92,7 +93,7 @@ class BaseActionCommand(BaseCommand): '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=4) + parser.add_argument('-w', '--worker', type=int, nargs="?", default=3 if os.cpu_count() > 3 else os.cpu_count()) parser.add_argument('-f', '--force', nargs="?", const=True) def initial_util(self, *args, **options): diff --git a/apps/common/management/commands/services/hands.py b/apps/common/management/commands/services/hands.py index 239411c8b..82447024e 100644 --- a/apps/common/management/commands/services/hands.py +++ b/apps/common/management/commands/services/hands.py @@ -2,8 +2,6 @@ import logging import os import sys -from django.conf import settings - from smartdoc.const import CONFIG, PROJECT_DIR try: @@ -17,7 +15,7 @@ except ImportError as e: __version__ = 'Unknown' sys.exit(1) -HTTP_HOST = CONFIG.HTTP_BIND_HOST or '127.0.0.1' +HTTP_HOST = '0.0.0.0' HTTP_PORT = CONFIG.HTTP_LISTEN_PORT or 8080 DEBUG = CONFIG.DEBUG or False diff --git a/apps/common/management/commands/services/services/celery_base.py b/apps/common/management/commands/services/services/celery_base.py index 34fbd680e..0ae219bd5 100644 --- a/apps/common/management/commands/services/services/celery_base.py +++ b/apps/common/management/commands/services/services/celery_base.py @@ -1,3 +1,5 @@ +from django.conf import settings + from .base import BaseService from ..hands import * diff --git a/installer/Dockerfile b/installer/Dockerfile index 9fdd8efdc..c24c756e5 100644 --- a/installer/Dockerfile +++ b/installer/Dockerfile @@ -48,7 +48,8 @@ ENV MAXKB_VERSION="${DOCKER_IMAGE_TAG} (build at ${BUILD_AT}, commit: ${GITHUB_C POSTGRES_USER=root \ POSTGRES_PASSWORD=Password123@postgres \ PIP_TARGET=/var/lib/postgresql/data/python-packages \ - PYTHONPATH=/var/lib/postgresql/data/python-packages + PYTHONPATH=/var/lib/postgresql/data/python-packages \ + PYTHONUNBUFFERED=1 WORKDIR /opt/maxkb/app COPY --from=stage-build /opt/maxkb /opt/maxkb