erylee 13 лет назад
Родитель
Сommit
58b1e258c1

+ 12 - 0
plugins/emqtt_plugin_admin/src/emqtt_plugin_admin.app.src

@@ -0,0 +1,12 @@
+{application, emqtt_plugin_admin,
+ [
+  {description, ""},
+  {vsn, "1"},
+  {registered, []},
+  {applications, [
+                  kernel,
+                  stdlib
+                 ]},
+  {mod, { emqtt_plugin_admin_app, []}},
+  {env, []}
+ ]}.

+ 16 - 0
plugins/emqtt_plugin_admin/src/emqtt_plugin_admin_app.erl

@@ -0,0 +1,16 @@
+-module(emqtt_plugin_admin_app).
+
+-behaviour(application).
+
+%% Application callbacks
+-export([start/2, stop/1]).
+
+%% ===================================================================
+%% Application callbacks
+%% ===================================================================
+
+start(_StartType, _StartArgs) ->
+    emqtt_plugin_admin_sup:start_link().
+
+stop(_State) ->
+    ok.

+ 28 - 0
plugins/emqtt_plugin_admin/src/emqtt_plugin_admin_sup.erl

@@ -0,0 +1,28 @@
+
+-module(emqtt_plugin_admin_sup).
+
+-behaviour(supervisor).
+
+%% API
+-export([start_link/0]).
+
+%% Supervisor callbacks
+-export([init/1]).
+
+%% Helper macro for declaring children of supervisor
+-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
+
+%% ===================================================================
+%% API functions
+%% ===================================================================
+
+start_link() ->
+    supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+
+%% ===================================================================
+%% Supervisor callbacks
+%% ===================================================================
+
+init([]) ->
+    {ok, { {one_for_one, 5, 10}, []} }.
+

+ 6 - 1
src/emqtt_ctl.erl

@@ -25,9 +25,14 @@ cluster_info([]) ->
 cluster([Node]) ->
 	case net_adm:ping(list_to_atom(Node)) of
 	pong ->
+		application:stop(emqtt),
+		mnesia:stop(),
+		mnesia:start(),
+		mnesia:change_config(extra_db_nodes, [Node]),
+		application:start(emqtt),
 		?PRINT("cluster with ~p successfully.~n", [Node]);
 	pang ->
-        ?PRINT("failed to cluster with ~p~n", [Node])
+        ?PRINT("failed to connect to ~p~n", [Node])
 	end.
 
 add_user([Username, Password]) ->