1
0
Эх сурвалжийг харах

fix: 修复gunicorn日志的位置

SongZihuan 2 жил өмнө
parent
commit
1e146b090b
1 өөрчлөгдсөн 4 нэмэгдсэн , 3 устгасан
  1. 4 3
      gunicorn.conf.py

+ 4 - 3
gunicorn.conf.py

@@ -12,7 +12,8 @@ workers = multiprocessing.cpu_count() * 2 + 1  # 进程数
 threads = 2  # 指定每个进程开启的线程数
 
 henglish_path = os.path.join(os.environ['HOME'], "henglish")
-os.makedirs(os.path.join(henglish_path, "log"), exist_ok=True, mode=0o775)
+log_path = os.path.join(henglish_path, "log")
+os.makedirs(log_path, exist_ok=True, mode=0o775)
 
 # 设置访问日志和错误信息日志路径
 log_format = ("%(levelname)s:%(name)s:%(asctime)s "
@@ -25,7 +26,7 @@ log_formatter = logging.Formatter(log_format)
 gunicorn_error_logger = logging.getLogger("gunicorn.error")
 gunicorn_error_logger.setLevel(logging.WARNING)
 
-errorlog = os.path.join(henglish_path, "gunicorn_error.log")
+errorlog = os.path.join(log_path, "gunicorn_error.log")
 time_handle = logging.handlers.TimedRotatingFileHandler(errorlog, when="d", backupCount=30, encoding='utf-8')
 gunicorn_error_logger.addHandler(time_handle)
 time_handle.setFormatter(log_formatter)
@@ -34,7 +35,7 @@ time_handle.setFormatter(log_formatter)
 gunicorn_access_logger = logging.getLogger("gunicorn.access")
 gunicorn_access_logger.setLevel(logging.INFO)
 
-accesslog = os.path.join(henglish_path, "gunicorn_access.log")
+accesslog = os.path.join(log_path, "gunicorn_access.log")
 time_handle = logging.handlers.TimedRotatingFileHandler(accesslog, when="d", backupCount=10, encoding='utf-8')
 gunicorn_access_logger.addHandler(time_handle)
 time_handle.setFormatter(log_formatter)