replace 'emqttd:conf' with 'emqttd:env'

This commit is contained in:
Feng Lee 2016-10-11 09:46:28 +08:00
parent c0c79e8171
commit 2bcffab28a
3 changed files with 9 additions and 16 deletions

View File

@ -27,7 +27,7 @@
-export([list/0]).
init() ->
case emqttd:conf(plugins_etc_dir) of
case emqttd:env(plugins_etc_dir) of
{ok, PluginsEtc} ->
CfgFiles = filelib:wildcard("*.conf", PluginsEtc),
lists:foreach(fun(CfgFile) ->
@ -42,7 +42,7 @@ init() ->
%% @doc Load all plugins when the broker started.
-spec(load() -> list() | {error, any()}).
load() ->
case emqttd:conf(plugins_loaded_file) of
case emqttd:env(plugins_loaded_file) of
{ok, File} ->
ensure_file(File),
with_loaded_file(File, fun(Names) -> load_plugins(Names, false) end);
@ -75,7 +75,7 @@ load_plugins(Names, Persistent) ->
%% @doc Unload all plugins before broker stopped.
-spec(unload() -> list() | {error, any()}).
unload() ->
case emqttd:conf(plugins_loaded_file) of
case emqttd:env(plugins_loaded_file) of
{ok, File} ->
with_loaded_file(File, fun stop_plugins/1);
undefined ->
@ -89,7 +89,7 @@ stop_plugins(Names) ->
%% @doc List all available plugins
-spec(list() -> [mqtt_plugin()]).
list() ->
case emqttd:conf(plugins_etc_dir) of
case emqttd:env(plugins_etc_dir) of
{ok, PluginsEtc} ->
CfgFiles = filelib:wildcard("*.conf", PluginsEtc),
Plugins = [plugin(CfgFile) || CfgFile <- CfgFiles],
@ -244,7 +244,7 @@ plugin_unloaded(Name, true) ->
end.
read_loaded() ->
case emqttd:conf(plugins_loaded_file) of
case emqttd:env(plugins_loaded_file) of
{ok, File} -> read_loaded(File);
undefined -> {error, not_found}
end.
@ -252,7 +252,7 @@ read_loaded() ->
read_loaded(File) -> file:consult(File).
write_loaded(AppNames) ->
{ok, File} = emqttd:conf(plugins_loaded_file),
{ok, File} = emqttd:env(plugins_loaded_file),
case file:open(File, [binary, write]) of
{ok, Fd} ->
lists:foreach(fun(Name) ->

View File

@ -448,7 +448,7 @@ authenticate(Client, Password) ->
%% PUBLISH ACL is cached in process dictionary.
check_acl(publish, Topic, Client) ->
IfCache = emqttd:conf(cache_acl, true),
IfCache = emqttd:env(cache_acl, true),
case {IfCache, get({acl, publish, Topic})} of
{true, undefined} ->
AllowDeny = emqttd_access_control:check_acl(Client, publish, Topic),

View File

@ -28,15 +28,8 @@ start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
init([]) ->
Sysmon = {sysmon, {emqttd_sysmon, start_link, [opts()]},
{ok, Env} = emqttd:env(sysmon),
Sysmon = {sysmon, {emqttd_sysmon, start_link, [Env]},
permanent, 5000, worker, [emqttd_sysmon]},
{ok, {{one_for_one, 10, 100}, [Sysmon]}}.
opts() ->
Opts = [{long_gc, emqttd:conf(sysmon_long_gc)},
{long_schedule, emqttd:conf(sysmon_long_schedule)},
{large_heap, emqttd:conf(sysmon_large_heap)},
{busy_port, emqttd:conf(busy_port)},
{busy_dist_port, emqttd:conf(sysmon_busy_dist_port)}],
[{Key, Val} || {Key, {ok, Val}} <- Opts].