Skip to content

Commit

Permalink
add USE_DOCKER_LOGS env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
cdhigh committed Nov 27, 2024
1 parent 59607dc commit 9dffb04
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 52 deletions.
12 changes: 10 additions & 2 deletions application/static/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion application/templates/my.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</div>
</div>

<legend>{{_("Subscribed")}}</legend>
<legend id="legend_mysubscribed">{{_("Subscribed")}}</legend>
<div id="mysubscribed" class="box-list">
<!-- 由脚本在这里填充数据 -->
</div>
Expand Down
98 changes: 51 additions & 47 deletions docker/gunicorn.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
9 changes: 8 additions & 1 deletion docs/Chinese/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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用户组

Expand All @@ -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'`



<a id="oracle-cloud"></a>
Expand Down
9 changes: 8 additions & 1 deletion docs/English/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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'`.



<a id="oracle-cloud"></a>
Expand Down

0 comments on commit 9dffb04

Please sign in to comment.