diff --git a/config/sys-prod.config b/config/sys-prod.config deleted file mode 100644 index c5973b9..0000000 --- a/config/sys-prod.config +++ /dev/null @@ -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"]}} - } - } - - ]} - ]} - -]. diff --git a/config/sys-test.config b/config/sys-test.config deleted file mode 100644 index acf4650..0000000 --- a/config/sys-test.config +++ /dev/null @@ -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"]}} - } - } - - ]} - ]} - -]. diff --git a/config/sys-dev.config b/config/sys.config.src similarity index 66% rename from config/sys-dev.config rename to config/sys.config.src index 5466f0c..071110e 100644 --- a/config/sys-dev.config +++ b/config/sys.config.src @@ -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"]}} } } diff --git a/config/vm.args b/config/vm.args deleted file mode 100644 index bd45d19..0000000 --- a/config/vm.args +++ /dev/null @@ -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 diff --git a/config/vm.args.src b/config/vm.args.src new file mode 100644 index 0000000..772c97a --- /dev/null +++ b/config/vm.args.src @@ -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} diff --git a/rebar.config b/rebar.config index 7a6a118..2b115e4 100644 --- a/rebar.config +++ b/rebar.config @@ -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}