fix plugins
This commit is contained in:
parent
c40d59d3cc
commit
3f9de8c073
|
@ -150,7 +150,6 @@
|
||||||
name,
|
name,
|
||||||
version,
|
version,
|
||||||
descr,
|
descr,
|
||||||
config,
|
|
||||||
active = false
|
active = false
|
||||||
}).
|
}).
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ list() ->
|
||||||
case emqttd:conf(plugins_etc_dir) of
|
case emqttd:conf(plugins_etc_dir) of
|
||||||
{ok, PluginsEtc} ->
|
{ok, PluginsEtc} ->
|
||||||
CfgFiles = filelib:wildcard("*.conf", PluginsEtc),
|
CfgFiles = filelib:wildcard("*.conf", PluginsEtc),
|
||||||
Plugins = [plugin(PluginsEtc, CfgFile) || CfgFile <- CfgFiles],
|
Plugins = [plugin(CfgFile) || CfgFile <- CfgFiles],
|
||||||
StartedApps = names(started_app),
|
StartedApps = names(started_app),
|
||||||
lists:map(fun(Plugin = #mqtt_plugin{name = Name}) ->
|
lists:map(fun(Plugin = #mqtt_plugin{name = Name}) ->
|
||||||
case lists:member(Name, StartedApps) of
|
case lists:member(Name, StartedApps) of
|
||||||
|
@ -89,13 +89,12 @@ list() ->
|
||||||
[]
|
[]
|
||||||
end.
|
end.
|
||||||
|
|
||||||
plugin(PluginsEtc, CfgFile0) ->
|
plugin(CfgFile) ->
|
||||||
CfgFile = filename:join(PluginsEtc, CfgFile0),
|
[AppName | _] = sting:tokens(CfgFile, "."),
|
||||||
{ok, [[{AppName, AppEnv} | _]]} = file:consult(CfgFile),
|
|
||||||
{ok, Attrs} = application:get_all_key(AppName),
|
{ok, Attrs} = application:get_all_key(AppName),
|
||||||
Ver = proplists:get_value(vsn, Attrs, "0"),
|
Ver = proplists:get_value(vsn, Attrs, "0"),
|
||||||
Descr = proplists:get_value(description, Attrs, ""),
|
Descr = proplists:get_value(description, Attrs, ""),
|
||||||
#mqtt_plugin{name = AppName, version = Ver, config = AppEnv, descr = Descr}.
|
#mqtt_plugin{name = AppName, version = Ver, descr = Descr}.
|
||||||
|
|
||||||
%% @doc Load a Plugin
|
%% @doc Load a Plugin
|
||||||
-spec(load(atom()) -> ok | {error, any()}).
|
-spec(load(atom()) -> ok | {error, any()}).
|
||||||
|
@ -114,15 +113,15 @@ load(PluginName) when is_atom(PluginName) ->
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
load_plugin(#mqtt_plugin{name = Name, config = Config}, Persistent) ->
|
load_plugin(#mqtt_plugin{name = Name}, Persistent) ->
|
||||||
case load_app(Name, Config) of
|
case load_app(Name) of
|
||||||
ok ->
|
ok ->
|
||||||
start_app(Name, fun(App) -> plugin_loaded(App, Persistent) end);
|
start_app(Name, fun(App) -> plugin_loaded(App, Persistent) end);
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
{error, Error}
|
{error, Error}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
load_app(App, _Config) ->
|
load_app(App) ->
|
||||||
case application:load(App) of
|
case application:load(App) of
|
||||||
ok ->
|
ok ->
|
||||||
ok;
|
ok;
|
||||||
|
|
Loading…
Reference in New Issue