is_mod_enabled
This commit is contained in:
parent
ced7acbf1c
commit
c2d4a60dec
|
@ -32,7 +32,7 @@
|
||||||
open_listeners/1, close_listeners/1,
|
open_listeners/1, close_listeners/1,
|
||||||
load_all_plugins/0, unload_all_plugins/0,
|
load_all_plugins/0, unload_all_plugins/0,
|
||||||
load_plugin/1, unload_plugin/1,
|
load_plugin/1, unload_plugin/1,
|
||||||
load_all_mods/0,
|
load_all_mods/0, is_mod_enabled/1,
|
||||||
loaded_plugins/0,
|
loaded_plugins/0,
|
||||||
is_running/1]).
|
is_running/1]).
|
||||||
|
|
||||||
|
@ -211,6 +211,9 @@ load_all_mods() ->
|
||||||
lager:info("load module ~s successfully", [Name])
|
lager:info("load module ~s successfully", [Name])
|
||||||
end, Mods).
|
end, Mods).
|
||||||
|
|
||||||
|
is_mod_enabled(Name) ->
|
||||||
|
env(modules, Name) =/= undefined.
|
||||||
|
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
%% @doc Is running?
|
%% @doc Is running?
|
||||||
%% @end
|
%% @end
|
||||||
|
|
|
@ -41,7 +41,8 @@
|
||||||
|
|
||||||
load(Opts) ->
|
load(Opts) ->
|
||||||
File = proplists:get_value(file, Opts),
|
File = proplists:get_value(file, Opts),
|
||||||
Sections = compile(file:consult(File)),
|
{ok, Terms} = file:consult(File),
|
||||||
|
Sections = compile(Terms),
|
||||||
emqttd_broker:hook(client_subscribe, {?MODULE, rewrite_subscribe},
|
emqttd_broker:hook(client_subscribe, {?MODULE, rewrite_subscribe},
|
||||||
{?MODULE, rewrite, [subscribe, Sections]}),
|
{?MODULE, rewrite, [subscribe, Sections]}),
|
||||||
emqttd_broker:hook(client_unsubscribe, {?MODULE, rewrite_unsubscribe},
|
emqttd_broker:hook(client_unsubscribe, {?MODULE, rewrite_unsubscribe},
|
||||||
|
|
|
@ -137,7 +137,7 @@ handle(Packet = ?CONNECT_PACKET(Var), State = #proto_state{peername = Peername =
|
||||||
%% Start keepalive
|
%% Start keepalive
|
||||||
start_keepalive(KeepAlive),
|
start_keepalive(KeepAlive),
|
||||||
%% Run hooks
|
%% Run hooks
|
||||||
emqttd_broker:run_hooks(client_connected, [{self(), ClientId1}]),
|
emqttd_broker:foreach_hooks(client_connected, [{self(), ClientId1}]),
|
||||||
{?CONNACK_ACCEPT, State1#proto_state{clientid = ClientId1,
|
{?CONNACK_ACCEPT, State1#proto_state{clientid = ClientId1,
|
||||||
session = Session,
|
session = Session,
|
||||||
will_msg = willmsg(Var)}};
|
will_msg = willmsg(Var)}};
|
||||||
|
|
|
@ -46,14 +46,14 @@
|
||||||
%% Authentication with username, password
|
%% Authentication with username, password
|
||||||
%{username, []},
|
%{username, []},
|
||||||
%% Authentication with clientid
|
%% Authentication with clientid
|
||||||
%{clientid, [{password, no}, {file, "etc/conf/clients.config"}]},
|
%{clientid, [{password, no}, {file, "etc/clients.config"}]},
|
||||||
%% Allow all
|
%% Allow all
|
||||||
{anonymous, []}
|
{anonymous, []}
|
||||||
]},
|
]},
|
||||||
%% ACL config
|
%% ACL config
|
||||||
{acl, [
|
{acl, [
|
||||||
%% Internal ACL module
|
%% Internal ACL module
|
||||||
{internal, [{file, "etc/conf/acl.config"}, {nomatch, allow}]}
|
{internal, [{file, "etc/acl.config"}, {nomatch, allow}]}
|
||||||
]}
|
]}
|
||||||
]},
|
]},
|
||||||
%% MQTT Protocol Options
|
%% MQTT Protocol Options
|
||||||
|
@ -111,7 +111,7 @@
|
||||||
%% Subscribe topics automatically when client connected
|
%% Subscribe topics automatically when client connected
|
||||||
{autosub, [{"$Q/client/$c", 0}]},
|
{autosub, [{"$Q/client/$c", 0}]},
|
||||||
%% Rewrite rules
|
%% Rewrite rules
|
||||||
{rewrite, [{file, "etc/conf/rewrite.config"}]}
|
{rewrite, [{file, "etc/rewrite.config"}]}
|
||||||
|
|
||||||
]},
|
]},
|
||||||
%% Listeners
|
%% Listeners
|
||||||
|
|
|
@ -64,7 +64,6 @@
|
||||||
{mkdir, "log/"},
|
{mkdir, "log/"},
|
||||||
{mkdir, "etc/"},
|
{mkdir, "etc/"},
|
||||||
{mkdir, "etc/ssl/"},
|
{mkdir, "etc/ssl/"},
|
||||||
{mkdir, "etc/conf/"},
|
|
||||||
{mkdir, "data/"},
|
{mkdir, "data/"},
|
||||||
{mkdir, "plugins/"},
|
{mkdir, "plugins/"},
|
||||||
{copy, "files/erl", "\{\{erts_vsn\}\}/bin/erl"},
|
{copy, "files/erl", "\{\{erts_vsn\}\}/bin/erl"},
|
||||||
|
@ -77,9 +76,9 @@
|
||||||
{copy, "files/ssl/ssl.crt", "etc/ssl/ssl.crt"},
|
{copy, "files/ssl/ssl.crt", "etc/ssl/ssl.crt"},
|
||||||
{copy, "files/ssl/ssl.key", "etc/ssl/ssl.key"},
|
{copy, "files/ssl/ssl.key", "etc/ssl/ssl.key"},
|
||||||
{template, "files/emqttd.config", "etc/emqttd.config"},
|
{template, "files/emqttd.config", "etc/emqttd.config"},
|
||||||
{template, "files/acl.config", "etc/conf/acl.config"},
|
{template, "files/acl.config", "etc/acl.config"},
|
||||||
{template, "files/rewrite.config", "etc/conf/rewrite.config"},
|
{template, "files/rewrite.config", "etc/rewrite.config"},
|
||||||
{template, "files/clients.config", "etc/conf/clients.config"},
|
{template, "files/clients.config", "etc/clients.config"},
|
||||||
{template, "files/plugins.config", "etc/plugins.config"},
|
{template, "files/plugins.config", "etc/plugins.config"},
|
||||||
{template, "files/vm.args", "etc/vm.args"}
|
{template, "files/vm.args", "etc/vm.args"}
|
||||||
]}.
|
]}.
|
||||||
|
|
Loading…
Reference in New Issue