修复Log文件输出不可用的问题
This commit is contained in:
parent
c858ede656
commit
1d9157c4b8
@ -39,18 +39,15 @@ end
|
||||
|
||||
-- 是否启用日志
|
||||
o = s:taboption("general", Flag, "enable_logging", translate("Enable logging"))
|
||||
o.enabled = "true"
|
||||
o.disabled = "false"
|
||||
o.default = o.enabled
|
||||
|
||||
-- 日志路径
|
||||
o = s:taboption("general", Value, "log_to", translate("Log file"))
|
||||
o:depends("enable_logging", "true")
|
||||
o:depends("enable_logging", "1")
|
||||
o.default = "/var/log/frps.log"
|
||||
|
||||
-- 日志等级
|
||||
o = s:taboption("general", ListValue, "log_level", translate("Log level"))
|
||||
o:depends("enable_logging", "true")
|
||||
o:depends("enable_logging", "1")
|
||||
o:value("trace", translate("Trace"))
|
||||
o:value("debug", translate("Debug"))
|
||||
o:value("info", translate("Info"))
|
||||
@ -61,7 +58,7 @@ o.default = "Warn"
|
||||
-- 日志保留天数
|
||||
o = s:taboption("general", ListValue, "log_maxdays", translate("Log max days"))
|
||||
o.description = translate("Maximum number of days to keep log files is 3 day.")
|
||||
o:depends("enable_logging", "true")
|
||||
o:depends("enable_logging", "1")
|
||||
o.datatype = "uinteger"
|
||||
o:value("1", translate("1"))
|
||||
o:value("2", translate("2"))
|
||||
@ -77,7 +74,7 @@ o.optional = false
|
||||
o = s:taboption("general", Flag, "log_disable_print_color", translate("Disable log color"))
|
||||
o.enabled = "true"
|
||||
o.disabled = "false"
|
||||
o.default = o.enabled
|
||||
o.default = o.disabled
|
||||
|
||||
-- 允许客户端设置的最大连接池大小
|
||||
o = s:taboption("advanced", Value, "transport_max_pool_count", translate("Max pool count"))
|
||||
|
@ -73,7 +73,7 @@ append_options() {
|
||||
;;
|
||||
"enable_prometheus")
|
||||
echo "enablePrometheus = $v" >>"$file"
|
||||
;;
|
||||
;;
|
||||
"webserver_addr")
|
||||
echo "webServer.addr = \"$v\"" >>"$file"
|
||||
;;
|
||||
@ -137,7 +137,7 @@ frps_scetion_validate() {
|
||||
'webserver_user:string' \
|
||||
'webserver_password:string' \
|
||||
'sub_domain_host:host' \
|
||||
'enable_logging:or("true", "false"):false' \
|
||||
'enable_logging:bool:0' \
|
||||
'log_to:string:/var/log/frps.log' \
|
||||
'log_level:or("trace", "debug", "info", "warn", "error"):warn' \
|
||||
'log_maxdays:uinteger:3' \
|
||||
@ -164,21 +164,21 @@ create_config_file() {
|
||||
local tmp_file="$(mktemp /tmp/frps-XXXXXX)"
|
||||
|
||||
append_options "$tmp_file" \
|
||||
"bind_addr" "bind_port" "auth_token" "tls_force" "kcp_bind_port" "quic_bind_port" "vhost_http_port" "vhost_https_port" "tcpmux_http_connect_port"
|
||||
"bind_addr" "bind_port" "auth_token" "tls_force" "kcp_bind_port" "quic_bind_port" "vhost_http_port" "vhost_https_port" "tcpmux_http_connect_port" "log_disable_print_color"
|
||||
|
||||
|
||||
if [ "x$enable_logging" = "x1" ] ; then
|
||||
if [ -z "$log_file" ]; then
|
||||
log_file="/var/log/frps.log"
|
||||
if [ -z "$log_to" ]; then
|
||||
log_to="/var/log/frps.log"
|
||||
fi
|
||||
|
||||
append_options "$tmp_file" \
|
||||
"log_to" "log_level" "log_maxdays" "log_disable_print_color"
|
||||
"log_to" "log_level" "log_maxdays"
|
||||
|
||||
if [ -f "$log_file" ] ; then
|
||||
echo > "$log_file"
|
||||
if [ -f "$log_to" ] ; then
|
||||
echo > "$log_to"
|
||||
else
|
||||
local log_folder="$(dirname "$log_file")"
|
||||
local log_folder="$(dirname "$log_to")"
|
||||
|
||||
if [ ! -d "$log_folder" ] ; then
|
||||
mkdir -p "$log_folder"
|
||||
@ -186,8 +186,8 @@ create_config_file() {
|
||||
fi
|
||||
|
||||
if [ -n "$run_user" ] && ( user_exists "$run_user" ) ; then
|
||||
chmod 644 "$log_file"
|
||||
chown "$run_user" "$log_file"
|
||||
chmod 644 "$log_to"
|
||||
chown "$run_user" "$log_to"
|
||||
else
|
||||
run_user=""
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user