fix(config): read app env 'config_files' to get the path to emqx.conf
This commit is contained in:
parent
27d5c5b2d9
commit
0ac2492b36
|
@ -29,13 +29,6 @@ node {
|
||||||
## Default: "{{ platform_data_dir }}/"
|
## Default: "{{ platform_data_dir }}/"
|
||||||
data_dir: "{{ platform_data_dir }}/"
|
data_dir: "{{ platform_data_dir }}/"
|
||||||
|
|
||||||
## The config file dir where the emqx.conf can be found
|
|
||||||
##
|
|
||||||
## @doc node.etc_dir
|
|
||||||
## ValueType: Folder
|
|
||||||
## Default: "{{ platform_etc_dir }}/"
|
|
||||||
etc_dir: "{{ platform_etc_dir }}/"
|
|
||||||
|
|
||||||
## Dir of crash dump file.
|
## Dir of crash dump file.
|
||||||
##
|
##
|
||||||
## @doc node.crash_dump_dir
|
## @doc node.crash_dump_dir
|
||||||
|
|
|
@ -72,7 +72,7 @@ add_handler(ConfKeyPath, HandlerName) ->
|
||||||
|
|
||||||
-spec init(term()) -> {ok, state()}.
|
-spec init(term()) -> {ok, state()}.
|
||||||
init(_) ->
|
init(_) ->
|
||||||
{ok, RawConf} = hocon:load(emqx_conf_name(), #{format => richmap}),
|
RawConf = load_config_file(),
|
||||||
{_MappedEnvs, Conf} = hocon_schema:map_translate(emqx_schema, RawConf, #{}),
|
{_MappedEnvs, Conf} = hocon_schema:map_translate(emqx_schema, RawConf, #{}),
|
||||||
ok = save_config_to_emqx(to_plainmap(Conf), to_plainmap(RawConf)),
|
ok = save_config_to_emqx(to_plainmap(Conf), to_plainmap(RawConf)),
|
||||||
{ok, #{handlers => #{?MOD => ?MODULE}}}.
|
{ok, #{handlers => #{?MOD => ?MODULE}}}.
|
||||||
|
@ -192,14 +192,15 @@ read_old_config(FileName) ->
|
||||||
_ -> #{}
|
_ -> #{}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
emqx_conf_name() ->
|
load_config_file() ->
|
||||||
filename:join([etc_dir(), "emqx.conf"]).
|
lists:foldl(fun(ConfFile, Acc) ->
|
||||||
|
{ok, RawConf} = hocon:load(ConfFile, #{format => richmap}),
|
||||||
|
emqx_map_lib:deep_merge(Acc, RawConf)
|
||||||
|
end, #{}, emqx:get_env(config_files, [])).
|
||||||
|
|
||||||
emqx_override_conf_name() ->
|
emqx_override_conf_name() ->
|
||||||
filename:join([emqx:get_env(data_dir), "emqx_override.conf"]).
|
filename:join([emqx:get_env(data_dir), "emqx_override.conf"]).
|
||||||
|
|
||||||
etc_dir() ->
|
|
||||||
emqx:get_env(etc_dir).
|
|
||||||
|
|
||||||
to_richmap(Map) ->
|
to_richmap(Map) ->
|
||||||
{ok, RichMap} = hocon:binary(jsx:encode(Map), #{format => richmap}),
|
{ok, RichMap} = hocon:binary(jsx:encode(Map), #{format => richmap}),
|
||||||
|
|
|
@ -99,7 +99,8 @@ do_start_listener(ZoneName, ListenerName, #{type := quic, bind := ListenOn} = Op
|
||||||
, peer_bidi_stream_count => 10
|
, peer_bidi_stream_count => 10
|
||||||
},
|
},
|
||||||
StreamOpts = [],
|
StreamOpts = [],
|
||||||
quicer:start_listener('mqtt:quic', port(ListenOn), {ListenOpts, ConnectionOpts, StreamOpts}).
|
quicer:start_listener(listener_id(ZoneName, ListenerName),
|
||||||
|
port(ListenOn), {ListenOpts, ConnectionOpts, StreamOpts}).
|
||||||
|
|
||||||
esockd_opts(Opts0) ->
|
esockd_opts(Opts0) ->
|
||||||
Opts1 = maps:with([acceptors, max_connections, proxy_protocol, proxy_protocol_timeout], Opts0),
|
Opts1 = maps:with([acceptors, max_connections, proxy_protocol, proxy_protocol_timeout], Opts0),
|
||||||
|
@ -178,7 +179,9 @@ stop_listener(ListenerId) ->
|
||||||
stop_listener(ZoneName, ListenerName, #{type := tcp, bind := ListenOn}) ->
|
stop_listener(ZoneName, ListenerName, #{type := tcp, bind := ListenOn}) ->
|
||||||
esockd:close(listener_id(ZoneName, ListenerName), ListenOn);
|
esockd:close(listener_id(ZoneName, ListenerName), ListenOn);
|
||||||
stop_listener(ZoneName, ListenerName, #{type := ws}) ->
|
stop_listener(ZoneName, ListenerName, #{type := ws}) ->
|
||||||
cowboy:stop_listener(listener_id(ZoneName, ListenerName)).
|
cowboy:stop_listener(listener_id(ZoneName, ListenerName));
|
||||||
|
stop_listener(ZoneName, ListenerName, #{type := quic}) ->
|
||||||
|
quicer:stop_listener(listener_id(ZoneName, ListenerName)).
|
||||||
|
|
||||||
merge_default(Options) ->
|
merge_default(Options) ->
|
||||||
case lists:keytake(tcp_options, 1, Options) of
|
case lists:keytake(tcp_options, 1, Options) of
|
||||||
|
|
|
@ -146,7 +146,9 @@ fields("node") ->
|
||||||
override_env => "EMQX_NODE_COOKIE"
|
override_env => "EMQX_NODE_COOKIE"
|
||||||
})}
|
})}
|
||||||
, {"data_dir", t(string(), "emqx.data_dir", undefined)}
|
, {"data_dir", t(string(), "emqx.data_dir", undefined)}
|
||||||
, {"etc_dir", t(string(), "emqx.etc_dir", undefined)}
|
, {"config_files", t(list(string()), "emqx.config_files",
|
||||||
|
[ filename:join([os:getenv("RUNNER_ETC_DIR"), "emqx.conf"])
|
||||||
|
])}
|
||||||
, {"global_gc_interval", t(duration_s(), "emqx.global_gc_interval", undefined)}
|
, {"global_gc_interval", t(duration_s(), "emqx.global_gc_interval", undefined)}
|
||||||
, {"crash_dump_dir", t(file(), "vm_args.-env ERL_CRASH_DUMP", undefined)}
|
, {"crash_dump_dir", t(file(), "vm_args.-env ERL_CRASH_DUMP", undefined)}
|
||||||
, {"dist_net_ticktime", t(integer(), "vm_args.-kernel net_ticktime", undefined)}
|
, {"dist_net_ticktime", t(integer(), "vm_args.-kernel net_ticktime", undefined)}
|
||||||
|
|
1
bin/emqx
1
bin/emqx
|
@ -194,6 +194,7 @@ relx_nodetool() {
|
||||||
|
|
||||||
call_hocon() {
|
call_hocon() {
|
||||||
export RUNNER_ROOT_DIR
|
export RUNNER_ROOT_DIR
|
||||||
|
export RUNNER_ETC_DIR
|
||||||
export REL_VSN
|
export REL_VSN
|
||||||
"$ERTS_DIR/bin/escript" "$ROOTDIR/bin/nodetool" hocon "$@"
|
"$ERTS_DIR/bin/escript" "$ROOTDIR/bin/nodetool" hocon "$@"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue