处理配置文件

This commit is contained in:
anlicheng 2026-05-30 16:12:08 +08:00
parent 3defc05815
commit d65755b890
6 changed files with 31 additions and 196 deletions

View File

@ -1,76 +0,0 @@
[
{iot, [
{http_server, [
{port, 18080},
{acceptors, 5},
{max_connections, 1024},
{backlog, 1024}
]},
{ssl_server, [
{port, 1443},
{acceptors, 5},
{max_connections, 1024},
{backlog, 1024}
]},
{udp_server, [
{port, 18080}
]},
{api_url, "https://lgsiot.njau.edu.cn/api/v1/taskLog"}
]},
{endpoint, [
{endpoints, [
{root_dir, "/var/lib/endpoint/database/"},
{support_protocols, [
http
]}
]},
{endpoint_log, [
{path, "/var/lib/endpoint/endpoint_log/unmatched_publish.log"},
{max_bytes, 10485760},
{max_files, 10}
]}
]},
%% 系统日志配置,使用 OTP logger
{kernel, [
%% 设置 Logger 的 primary log level
{logger_level, debug},
{logger, [
{handler, default, logger_std_h,
#{
level => debug,
filter_default => stop,
filters => [
{iot_domain, {fun logger_filters:domain/2, {log, sub, [iot]}}},
{endpoint_domain, {fun logger_filters:domain/2, {log, sub, [endpoint]}}}
],
formatter => {logger_formatter, #{template => [time, " [", level, "] ", msg, "\n"]}}
}
},
{handler, disk, logger_disk_log_h,
#{
level => debug,
filter_default => stop,
filters => [
{iot_domain, {fun logger_filters:domain/2, {log, sub, [iot]}}},
{endpoint_domain, {fun logger_filters:domain/2, {log, sub, [endpoint]}}}
],
config => #{
file => "log/debug.log",
max_no_files => 10,
max_no_bytes => 524288000
},
formatter => {logger_formatter, #{template => [time, " [", level, "] ", msg, "\n"]}}
}
}
]}
]}
].

View File

@ -1,77 +0,0 @@
[
{iot, [
{http_server, [
{port, 18090},
{acceptors, 5},
{max_connections, 1024},
{backlog, 1024}
]},
{ssl_server, [
{port, 1443},
{acceptors, 5},
{max_connections, 1024},
{backlog, 1024}
]},
{udp_server, [
{port, 18080}
]},
{api_url, "http://127.0.0.1/api/v1"}
]},
{endpoint, [
%% 支持的协议
{endpoints, [
{root_dir, "/usr/local/code/database/"},
{support_protocols, [
http
]}
]},
{endpoint_log, [
{path, "${endpoint_root}/endpoint_log/unmatched_publish.log"},
{max_bytes, 10485760},
{max_files, 10}
]}
]},
%% 系统日志配置,使用 OTP logger
{kernel, [
%% 设置 Logger 的 primary log level
{logger_level, debug},
{logger, [
{handler, default, logger_std_h,
#{
level => debug,
filter_default => stop,
filters => [
{iot_domain, {fun logger_filters:domain/2, {log, sub, [iot]}}},
{endpoint_domain, {fun logger_filters:domain/2, {log, sub, [endpoint]}}}
],
formatter => {logger_formatter, #{template => [time, " [", level, "] ", msg, "\n"]}}
}
},
{handler, disk, logger_disk_log_h,
#{
level => debug,
filter_default => stop,
filters => [
{iot_domain, {fun logger_filters:domain/2, {log, sub, [iot]}}},
{endpoint_domain, {fun logger_filters:domain/2, {log, sub, [endpoint]}}}
],
config => #{
file => "log/debug.log",
max_no_files => 10,
max_no_bytes => 524288000
},
formatter => {logger_formatter, #{template => [time, " [", level, "] ", msg, "\n"]}}
}
}
]}
]}
].

View File

@ -1,7 +1,7 @@
[
{iot, [
{http_server, [
{port, 18090},
{port, 18080},
{acceptors, 5},
{max_connections, 1024},
{backlog, 1024}
@ -18,33 +18,33 @@
{port, 18080}
]},
{api_url, "http://127.0.0.1:18090/simulator"}
{api_url, "${IOT_API_URL:-https://lgsiot.njau.edu.cn/api/v1/taskLog}"}
]},
{endpoint, [
%% 支持的协议
{endpoints, [
{root_dir, "/usr/local/code/database/"},
{root_dir, "${ENDPOINT_ROOT_DIR:-/var/lib/endpoint/database/}"},
{support_protocols, [
http
]}
]},
{endpoint_log, [
{path, "${endpoint_root}/endpoint_log/unmatched_publish.log"},
{max_bytes, 10485760},
{max_files, 10}
{path, "${ENDPOINT_LOG_PATH:-/var/lib/endpoint/endpoint_log/unmatched_publish.log}"},
{max_bytes, ${ENDPOINT_LOG_MAX_BYTES:-10485760}},
{max_files, ${ENDPOINT_LOG_MAX_FILES:-10}}
]}
]},
%% 系统日志配置,使用 OTP logger
{kernel, [
%% 设置 Logger 的 primary log level
{logger_level, debug},
{logger_level, ${IOT_LOG_LEVEL:-debug}},
{logger, [
{handler, default, logger_std_h,
#{
level => debug,
level => ${IOT_CONSOLE_LOG_LEVEL:-debug},
filter_default => stop,
filters => [
{iot_domain, {fun logger_filters:domain/2, {log, sub, [iot]}}},
@ -56,17 +56,17 @@
{handler, disk, logger_disk_log_h,
#{
level => debug,
level => ${IOT_DISK_LOG_LEVEL:-debug},
filter_default => stop,
filters => [
{iot_domain, {fun logger_filters:domain/2, {log, sub, [iot]}}},
{endpoint_domain, {fun logger_filters:domain/2, {log, sub, [endpoint]}}}
],
config => #{
file => "log/debug.log",
max_no_files => 10,
max_no_bytes => 524288000
},
file => "${IOT_DISK_LOG_FILE:-log/debug.log}",
max_no_files => ${IOT_DISK_LOG_MAX_FILES:-10},
max_no_bytes => ${IOT_DISK_LOG_MAX_BYTES:-524288000}
},
formatter => {logger_formatter, #{template => [time, " [", level, "] ", msg, "\n"]}}
}
}

View File

@ -1,17 +0,0 @@
-sname iot
-setcookie iot_cookie
+K true
+A30
-mnesia dir '"/var/lib/iot/mnesia/"'
-mnesia dump_log_write_threshold 50000
-mnesia dc_dump_limit 40
-sbt db
+K true
+A 128
+P 1048576
+t 10485760

15
config/vm.args.src Normal file
View File

@ -0,0 +1,15 @@
-sname ${IOT_NODE_NAME:-iot}
-setcookie ${IOT_COOKIE:-iot_cookie}
+K true
+A ${IOT_ASYNC_THREADS:-128}
-mnesia dir '"${IOT_MNESIA_DIR:-/var/lib/iot/mnesia/}"'
-mnesia dump_log_write_threshold ${IOT_MNESIA_DUMP_LOG_WRITE_THRESHOLD:-50000}
-mnesia dc_dump_limit ${IOT_MNESIA_DC_DUMP_LIMIT:-40}
-sbt ${IOT_SCHEDULER_BIND_TYPE:-db}
+P ${IOT_PROCESS_LIMIT:-1048576}
+t ${IOT_ATOM_LIMIT:-10485760}

View File

@ -23,25 +23,15 @@
{mode, prod},
%{mode, prod},
%% automatically picked up if the files
%% exist but can be set manually, which
%% is required if the names aren't exactly
%% sys.config and vm.args
{sys_config, "./config/sys-dev.config"},
{vm_args, "./config/vm.args"}
%% the .src form of the configuration files do
%% not require setting RELX_REPLACE_OS_VARS
%% {sys_config_src, "./config/sys.config.src"},
%% {vm_args_src, "./config/vm.args.src"}
{sys_config_src, "./config/sys.config.src"},
{vm_args_src, "./config/vm.args.src"}
]}.
{profiles, [{prod, [{relx,
[%% prod is the default mode when prod
%% profile is used, so does not have
%% to be explicitly included like this
{mode, prod},
{sys_config, "./config/sys-prod.config"}
{mode, prod}
%% use minimal mode to exclude ERTS
%% {mode, minimal}