From 9dffb041f5958719593e9abd68ea76dacdfbf6df Mon Sep 17 00:00:00 2001 From: cdhigh Date: Wed, 27 Nov 2024 11:04:51 -0300 Subject: [PATCH] add USE_DOCKER_LOGS env variable --- application/static/base.js | 12 ++++- application/templates/my.html | 2 +- docker/gunicorn.conf.py | 98 ++++++++++++++++++----------------- docs/Chinese/deployment.md | 9 +++- docs/English/deployment.md | 9 +++- 5 files changed, 78 insertions(+), 52 deletions(-) diff --git a/application/static/base.js b/application/static/base.js index 2da5e838..b8f345c3 100644 --- a/application/static/base.js +++ b/application/static/base.js @@ -344,9 +344,17 @@ function PopulateMyCustomRss() { function PopulateMySubscribed() { var $div = $('#mysubscribed'); $div.empty(); - for (var idx = 0; idx < my_booked_recipes.length; idx++) { + var bookNum = my_booked_recipes.length; + if (bookNum > 0) { + $('#legend_mysubscribed').show(); + $div.show(); + } else { + $('#legend_mysubscribed').hide(); + $div.hide(); + } + + for (var idx = 0; idx < bookNum; idx++) { var recipe = my_booked_recipes[idx]; - var title = escapeXml(recipe.title); var desc = recipe.description; var need_subs = recipe.needs_subscription; diff --git a/application/templates/my.html b/application/templates/my.html index 006f7a18..61fc9a2b 100644 --- a/application/templates/my.html +++ b/application/templates/my.html @@ -43,7 +43,7 @@ - {{_("Subscribed")}} + {{_("Subscribed")}}
diff --git a/docker/gunicorn.conf.py b/docker/gunicorn.conf.py index f575a151..5d167997 100644 --- a/docker/gunicorn.conf.py +++ b/docker/gunicorn.conf.py @@ -4,59 +4,63 @@ bind = "0.0.0.0:8000" workers = 1 threads = 3 -capture_output = True enable_stdio_inheritance = True -#accesslog = "/data/gunicorn.access.log" -#errorlog = "/data/gunicorn.error.log" -#loglevel = "info" #preload_app = True certfile = os.getenv('GUNI_CERT') keyfile = os.getenv('GUNI_KEY') #example: https://github.com/benoitc/gunicorn/blob/master/gunicorn/glogging.py -logconfig_dict = { - 'version': 1, - 'disable_existing_loggers': False, - "root": {"level": "INFO", "handlers": ["error_file"]}, - 'loggers': { - "gunicorn.error": { - "level": "INFO", - "handlers": ["error_file"], - "propagate": False, - "qualname": "gunicorn.error" +if os.getenv('USE_DOCKER_LOGS') == 'yes': + accesslog = "/data/gunicorn.access.log" + loglevel = os.getenv.get('LOG_LEVEL') or 'info' +else: + #accesslog = "/data/gunicorn.access.log" + #errorlog = "/data/gunicorn.error.log" + #loglevel = "info" + capture_output = True + logconfig_dict = { + 'version': 1, + 'disable_existing_loggers': False, + "root": {"level": "info", "handlers": ["error_file"]}, + 'loggers': { + "gunicorn.error": { + "level": os.getenv.get('LOG_LEVEL') or 'info', + "handlers": ["error_file"], + "propagate": False, + "qualname": "gunicorn.error" + }, + "gunicorn.access": { + "level": os.getenv.get('LOG_LEVEL') or 'info', + "handlers": ["access_file"], + "propagate": False, + "qualname": "gunicorn.access" + } }, - "gunicorn.access": { - "level": "INFO", - "handlers": ["access_file"], - "propagate": False, - "qualname": "gunicorn.access" - } - }, - 'handlers': { - "error_file": { - "class": "logging.handlers.RotatingFileHandler", - "maxBytes": 2*1024*1024, #2M, >20000lines - "backupCount": 1, - "formatter": "generic", - "filename": "/data/gunicorn.error.log" - }, - "access_file": { - "class": "logging.handlers.RotatingFileHandler", - "maxBytes": 500*1024, #500K >3000lines - "backupCount": 1, - "formatter": "access", - "filename": "/data/gunicorn.access.log" - } - }, - 'formatters':{ - "generic": { - "format": "[%(asctime)s] %(levelname)s [%(filename)s:%(lineno)s] %(message)s", - "datefmt": "%Y-%m-%d %H:%M:%S %z", - "class": "logging.Formatter" + 'handlers': { + "error_file": { + "class": "logging.handlers.RotatingFileHandler", + "maxBytes": 2*1024*1024, #2M, >20000lines + "backupCount": 1, + "formatter": "generic", + "filename": "/data/gunicorn.error.log" + }, + "access_file": { + "class": "logging.handlers.RotatingFileHandler", + "maxBytes": 500*1024, #500K >3000lines + "backupCount": 1, + "formatter": "access", + "filename": "/data/gunicorn.access.log" + } }, - "access": { - "format": "%(message)s", - "datefmt": "%Y-%m-%d %H:%M:%S %z", - "class": "logging.Formatter" + 'formatters':{ + "generic": { + "format": "[%(asctime)s] %(levelname)s [%(filename)s:%(lineno)s] %(message)s", + "datefmt": "%Y-%m-%d %H:%M:%S %z", + "class": "logging.Formatter" + }, + "access": { + "format": "%(message)s", + "datefmt": "%Y-%m-%d %H:%M:%S %z", + "class": "logging.Formatter" + } } } -} diff --git a/docs/Chinese/deployment.md b/docs/Chinese/deployment.md index 90426111..eba4aa98 100644 --- a/docs/Chinese/deployment.md +++ b/docs/Chinese/deployment.md @@ -173,11 +173,16 @@ sudo docker image prune -f 5. 需要查询日志文件 - +5.1. 默认 ```bash tail -n 100 ./data/gunicorn.error.log tail -n 100 ./data/gunicorn.access.log ``` +5.2. 设置环境变量后: `USE_DOCKER_LOGS='yes'` +```bash +docker logs container_name +``` + 6. 如果不喜欢每次输入docker都使用sudo,可以将你的账号添加到docker用户组 @@ -198,6 +203,8 @@ sudo usermod -aG docker your-username 3.2.2 在"存储空间设置"里面添加一个文件夹映射到 `/data`,比如 `/docker/data` 映射到 `/data`,权限为"读取/写入" 4. 启动完成后使用 http://ip:8001 访问。 5. 如果需要链接分享功能,可以设置环境变量 `APP_DOMAIN`。 +6. 如果希望使用群晖网页管理页面的logs查看KindleEar的异常记录,可以设置环境变量 `USE_DOCKER_LOGS='yes'`。 + diff --git a/docs/English/deployment.md b/docs/English/deployment.md index bd520603..739cf117 100644 --- a/docs/English/deployment.md +++ b/docs/English/deployment.md @@ -178,12 +178,17 @@ sudo docker image prune -f 5. To check log files - +5.1. Default ```bash tail -n 100 ./data/gunicorn.error.log tail -n 100 ./data/gunicorn.access.log ``` +5.2. After setting the environment variable: `USE_DOCKER_LOGS='yes'` +```bash +docker logs container_name +``` + 6. If you don't like using 'sudo' every time you use Docker, you can add your account to the 'docker' user group. @@ -204,6 +209,8 @@ sudo usermod -aG docker your-username 3.2.2. In the "Volume Settings", add a folder mapped to `/data`, for example, map `/docker/data` to `/data`, with "Read/Write" permissions. 4. After starting, access it via http://ip:8001. 5. If you need the link sharing feature, you can set the environment variable `APP_DOMAIN`. +6. To view KindleEar's error logs through the Synology web management interface, you can set the environment variable `USE_DOCKER_LOGS='yes'`. +