From 2898d25bf8958d0dfe3f9c80a05d8b63ce29adc4 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 13 Jul 2023 11:45:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=20log=20?= =?UTF-8?q?=E7=9A=84=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 1 - .gitignore | 1 - apps/common/management/commands/services/hands.py | 7 ++++--- apps/jumpserver/conf.py | 2 +- apps/jumpserver/settings/logging.py | 2 +- apps/jumpserver/urls.py | 7 +++++-- apps/manage.py | 3 +-- logs/.gitkeep | 1 - 8 files changed, 12 insertions(+), 12 deletions(-) delete mode 100644 logs/.gitkeep diff --git a/.dockerignore b/.dockerignore index 81c9033ba..0ddcc29ae 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,4 @@ .git -logs/* data/* .github tmp/* diff --git a/.gitignore b/.gitignore index 9573a70b7..985f77580 100644 --- a/.gitignore +++ b/.gitignore @@ -35,7 +35,6 @@ celerybeat-schedule.db docs/_build/ xpack xpack.bak -logs/* ### Vagrant ### .vagrant/ release/* diff --git a/apps/common/management/commands/services/hands.py b/apps/common/management/commands/services/hands.py index eb6aba418..c2e625e8b 100644 --- a/apps/common/management/commands/services/hands.py +++ b/apps/common/management/commands/services/hands.py @@ -1,12 +1,14 @@ +import logging import os import sys -import logging + from django.conf import settings from apps.jumpserver.const import CONFIG try: from apps.jumpserver import const + __version__ = const.VERSION except ImportError as e: print("Not found __version__: {}".format(e)) @@ -15,12 +17,11 @@ except ImportError as e: __version__ = 'Unknown' sys.exit(1) - HTTP_HOST = CONFIG.HTTP_BIND_HOST or '127.0.0.1' HTTP_PORT = CONFIG.HTTP_LISTEN_PORT or 8080 WS_PORT = CONFIG.WS_LISTEN_PORT or 8082 DEBUG = CONFIG.DEBUG or False BASE_DIR = os.path.dirname(settings.BASE_DIR) -LOG_DIR = os.path.join(BASE_DIR, 'logs') +LOG_DIR = os.path.join(BASE_DIR, 'data', 'logs') APPS_DIR = os.path.join(BASE_DIR, 'apps') TMP_DIR = os.path.join(BASE_DIR, 'tmp') diff --git a/apps/jumpserver/conf.py b/apps/jumpserver/conf.py index a0672422a..9faf6d64b 100644 --- a/apps/jumpserver/conf.py +++ b/apps/jumpserver/conf.py @@ -187,7 +187,7 @@ class Config(dict): 'DEBUG': False, 'DEBUG_DEV': False, 'LOG_LEVEL': 'DEBUG', - 'LOG_DIR': os.path.join(PROJECT_DIR, 'logs'), + 'LOG_DIR': os.path.join(PROJECT_DIR, 'data/logs'), 'DB_ENGINE': 'mysql', 'DB_NAME': 'jumpserver', 'DB_HOST': '127.0.0.1', diff --git a/apps/jumpserver/settings/logging.py b/apps/jumpserver/settings/logging.py index 6d4498e3f..c4cf90ebb 100644 --- a/apps/jumpserver/settings/logging.py +++ b/apps/jumpserver/settings/logging.py @@ -4,7 +4,7 @@ import os from ..const import PROJECT_DIR, CONFIG -LOG_DIR = os.path.join(PROJECT_DIR, 'logs') +LOG_DIR = os.path.join(PROJECT_DIR, 'data', 'logs') JUMPSERVER_LOG_FILE = os.path.join(LOG_DIR, 'jumpserver.log') DRF_EXCEPTION_LOG_FILE = os.path.join(LOG_DIR, 'drf_exception.log') UNEXPECTED_EXCEPTION_LOG_FILE = os.path.join(LOG_DIR, 'unexpected_exception.log') diff --git a/apps/jumpserver/urls.py b/apps/jumpserver/urls.py index f005f81f0..971995ffe 100644 --- a/apps/jumpserver/urls.py +++ b/apps/jumpserver/urls.py @@ -1,12 +1,12 @@ # ~*~ coding: utf-8 ~*~ from __future__ import unicode_literals + import os import private_storage.urls - -from django.urls import path, include, re_path from django.conf import settings from django.conf.urls.static import static +from django.urls import path, include, re_path from django.views.i18n import JavaScriptCatalog from . import views, api @@ -64,6 +64,9 @@ urlpatterns += [ # Protect media path('media/', include(private_storage.urls)), ] +if settings.DEBUG: + urlpatterns += static('/luna/', document_root=(settings.DATA_DIR + '/luna')) + urlpatterns += static('/lina/', document_root=(settings.DATA_DIR + '/lina')) # js i18n 路由文件 urlpatterns += [ diff --git a/apps/manage.py b/apps/manage.py index d24c5fd38..17f2ce477 100755 --- a/apps/manage.py +++ b/apps/manage.py @@ -1,11 +1,10 @@ #!/usr/bin/env python import os import sys -import errno if __name__ == "__main__": try: - os.makedirs('../logs') + os.makedirs('../data/logs') except: pass diff --git a/logs/.gitkeep b/logs/.gitkeep deleted file mode 100644 index 1a4baf536..000000000 --- a/logs/.gitkeep +++ /dev/null @@ -1 +0,0 @@ - From c1de9151b8d6c9f605c883f39ce71cf324f3acd0 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 13 Jul 2023 11:46:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?perf:=20=E4=BF=AE=E6=94=B9=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/jumpserver/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/jumpserver/conf.py b/apps/jumpserver/conf.py index 9faf6d64b..902f96df7 100644 --- a/apps/jumpserver/conf.py +++ b/apps/jumpserver/conf.py @@ -187,7 +187,7 @@ class Config(dict): 'DEBUG': False, 'DEBUG_DEV': False, 'LOG_LEVEL': 'DEBUG', - 'LOG_DIR': os.path.join(PROJECT_DIR, 'data/logs'), + 'LOG_DIR': os.path.join(PROJECT_DIR, 'data', 'logs'), 'DB_ENGINE': 'mysql', 'DB_NAME': 'jumpserver', 'DB_HOST': '127.0.0.1',