Przeglądaj źródła

fix: allow listener not_found before restart

Zaiming (Stone) Shi 4 lat temu
rodzic
commit
d3d8b3a01f

+ 3 - 2
apps/emqx/src/emqx_listeners.erl

@@ -175,9 +175,10 @@ restart_listener(Type, ListenerName, Conf) ->
     restart_listener(Type, ListenerName, Conf, Conf).
 
 restart_listener(Type, ListenerName, OldConf, NewConf) ->
-    case stop_listener(Type, ListenerName, OldConf) of
+    case do_stop_listener(Type, ListenerName, OldConf) of
         ok -> start_listener(Type, ListenerName, NewConf);
-        Error -> Error
+        {error, not_found} -> start_listener(Type, ListenerName, NewConf);
+        {error, Reason} -> {error, Reason}
     end.
 
 %% @doc Stop all listeners.

+ 2 - 2
apps/emqx/test/emqx_common_test_helpers.erl

@@ -120,6 +120,7 @@ all(Suite) ->
                       string:substr(atom_to_list(F), 1, 2) == "t_"
                 ]).
 
+%% set emqx app boot modules
 -spec(boot_modules(all|list(atom())) -> ok).
 boot_modules(Mods) ->
     application:set_env(emqx, boot_modules, Mods).
@@ -162,8 +163,7 @@ app_schema(App) ->
 mustache_vars(App) ->
     [{platform_data_dir, app_path(App, "data")},
      {platform_etc_dir,  app_path(App, "etc")},
-     {platform_log_dir,  app_path(App, "log")},
-     {platform_plugins_dir,  app_path(App, "plugins")}
+     {platform_log_dir,  app_path(App, "log")}
     ].
 
 start_app(App, Schema, ConfigFile, SpecAppConfig) ->

+ 1 - 6
apps/emqx/test/emqx_listeners_SUITE.erl

@@ -132,8 +132,7 @@ render_config_file() ->
 mustache_vars() ->
     [{platform_data_dir, local_path(["data"])},
      {platform_etc_dir,  local_path(["etc"])},
-     {platform_log_dir,  local_path(["log"])},
-     {platform_plugins_dir,  local_path(["plugins"])}
+     {platform_log_dir,  local_path(["log"])}
     ].
 
 generate_config() ->
@@ -144,10 +143,6 @@ generate_config() ->
 set_app_env({App, Lists}) ->
     lists:foreach(fun({authz_file, _Var}) ->
                       application:set_env(App, authz_file, local_path(["etc", "authz.conf"]));
-                     ({plugins_loaded_file, _Var}) ->
-                      application:set_env(App,
-                                          plugins_loaded_file,
-                                          local_path(["test", "emqx_SUITE_data","loaded_plugins"]));
                      ({Par, Var}) ->
                       application:set_env(App, Par, Var)
                   end, Lists).

+ 0 - 3
apps/emqx/test/emqx_persistent_session_SUITE.erl

@@ -160,9 +160,6 @@ init_per_group(gc_tests, Config) ->
 init_per_suite(Config) ->
     Config.
 
-set_special_confs(emqx) ->
-    Path = emqx_common_test_helpers:deps_path(emqx, "test/emqx_SUITE_data/loaded_plugins"),
-    application:set_env(emqx, plugins_loaded_file, Path);
 set_special_confs(_) ->
     ok.
 

+ 1 - 1
apps/emqx_plugins/etc/emqx_plugins.conf

@@ -3,5 +3,5 @@ plugins {
     }
     external {
     }
-    install_dir = "plugins"
+    install_dir = "{{ platform_plugins_dir }}"
 }

+ 4 - 2
apps/emqx_plugins/test/emqx_plugins_SUITE.erl

@@ -47,7 +47,9 @@ init_per_suite(Config) ->
     Config.
 
 end_per_suite(_Config) ->
-    emqx_common_test_helpers:stop_apps([]).
+    emqx_common_test_helpers:boot_modules(all),
+    emqx_common_test_helpers:stop_apps([]),
+    emqx_config:erase(plugins).
 
 t_load(_) ->
     ?assertEqual(ok, emqx_plugins:load()),
@@ -57,7 +59,7 @@ t_load(_) ->
     ?assertEqual({error, not_started}, emqx_plugins:unload(emqx_mini_plugin)),
     ?assertEqual({error, not_started}, emqx_plugins:unload(emqx_hocon_plugin)),
 
-    emqx_config:put([plugins, install_dir], undefined).
+    emqx_config:erase(plugins).
 
 t_load_ext_plugin(_) ->
     ?assertError({plugin_app_file_not_found, _},

+ 1 - 0
apps/emqx_retainer/test/emqx_retainer_SUITE.erl

@@ -55,6 +55,7 @@ init_per_suite(Config) ->
 
 end_per_suite(_Config) ->
     emqx_common_test_helpers:stop_apps([emqx_retainer]).
+
 %%--------------------------------------------------------------------
 %% Test Cases
 %%--------------------------------------------------------------------

+ 1 - 1
rebar.config.erl

@@ -257,7 +257,7 @@ overlay_vars_pkg(pkg) ->
     , {platform_etc_dir, "/etc/emqx"}
     , {platform_lib_dir, ""}
     , {platform_log_dir, "/var/log/emqx"}
-    , {platform_plugins_dir, "/var/lib/enqx/plugins"}
+    , {platform_plugins_dir, "/var/lib/emqx/plugins"}
     , {runner_root_dir, "/usr/lib/emqx"}
     , {runner_bin_dir, "/usr/bin"}
     , {runner_etc_dir, "/etc/emqx"}