Merge pull request #11909 from emqx/bugfix-plugins
fix: emqx failed to start if plugin dir is removed by the user
This commit is contained in:
commit
7bb3ca5519
|
@ -1,7 +1,7 @@
|
||||||
%% -*- mode: erlang -*-
|
%% -*- mode: erlang -*-
|
||||||
{application, emqx_plugins, [
|
{application, emqx_plugins, [
|
||||||
{description, "EMQX Plugin Management"},
|
{description, "EMQX Plugin Management"},
|
||||||
{vsn, "0.1.6"},
|
{vsn, "0.1.7"},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{mod, {emqx_plugins_app, []}},
|
{mod, {emqx_plugins_app, []}},
|
||||||
{applications, [kernel, stdlib, emqx]},
|
{applications, [kernel, stdlib, emqx]},
|
||||||
|
|
|
@ -433,9 +433,16 @@ do_ensure_started(NameVsn) ->
|
||||||
tryit(
|
tryit(
|
||||||
"start_plugins",
|
"start_plugins",
|
||||||
fun() ->
|
fun() ->
|
||||||
ok = ensure_exists_and_installed(NameVsn),
|
case ensure_exists_and_installed(NameVsn) of
|
||||||
Plugin = do_read_plugin(NameVsn),
|
ok ->
|
||||||
ok = load_code_start_apps(NameVsn, Plugin)
|
Plugin = do_read_plugin(NameVsn),
|
||||||
|
ok = load_code_start_apps(NameVsn, Plugin);
|
||||||
|
{error, plugin_not_found} ->
|
||||||
|
?SLOG(error, #{
|
||||||
|
msg => "plugin_not_found",
|
||||||
|
name_vsn => NameVsn
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
).
|
).
|
||||||
|
|
||||||
|
@ -665,6 +672,7 @@ do_load_plugin_app(AppName, Ebin) ->
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(BeamFile) ->
|
fun(BeamFile) ->
|
||||||
Module = list_to_atom(filename:basename(BeamFile, ".beam")),
|
Module = list_to_atom(filename:basename(BeamFile, ".beam")),
|
||||||
|
_ = code:purge(Module),
|
||||||
case code:load_file(Module) of
|
case code:load_file(Module) of
|
||||||
{module, _} ->
|
{module, _} ->
|
||||||
ok;
|
ok;
|
||||||
|
|
Loading…
Reference in New Issue