Call ekka_autocluster:bootstrap/0 to build the cluster

This commit is contained in:
Feng Lee 2017-07-18 18:40:03 +08:00
parent a23df7f16e
commit 437b26718b
3 changed files with 11 additions and 7 deletions

View File

@ -1,4 +1,4 @@
{deps, [
{goldrush,".*",{git,"https://github.com/basho/goldrush","0.1.9"}},{gproc,".*",{git,"https://github.com/uwiger/gproc",""}},{lager,".*",{git,"https://github.com/basho/lager","master"}},{esockd,".*",{git,"https://github.com/emqtt/esockd","master"}},{ekka,".*",{git,"https://github.com/emqtt/ekka","master"}},{mochiweb,".*",{git,"https://github.com/emqtt/mochiweb","master"}},{pbkdf2,".*",{git,"https://github.com/emqtt/pbkdf2","2.0.1"}},{lager_syslog,".*",{git,"https://github.com/basho/lager_syslog",""}},{bcrypt,".*",{git,"https://github.com/smarkets/erlang-bcrypt","master"}}
{goldrush,".*",{git,"https://github.com/basho/goldrush","0.1.9"}},{gproc,".*",{git,"https://github.com/uwiger/gproc",""}},{lager,".*",{git,"https://github.com/basho/lager","master"}},{esockd,".*",{git,"https://github.com/emqtt/esockd","master"}},{ekka,".*",{git,"https://github.com/emqtt/ekka","develop"}},{mochiweb,".*",{git,"https://github.com/emqtt/mochiweb","master"}},{pbkdf2,".*",{git,"https://github.com/emqtt/pbkdf2","2.0.1"}},{lager_syslog,".*",{git,"https://github.com/basho/lager_syslog",""}},{bcrypt,".*",{git,"https://github.com/smarkets/erlang-bcrypt","master"}}
]}.
{erl_opts, [debug_info,{parse_transform,lager_transform}]}.

View File

@ -39,14 +39,14 @@
start(_Type, _Args) ->
print_banner(),
ekka:start(),
%%ekka:start(),
{ok, Sup} = emqttd_sup:start_link(),
start_servers(Sup),
emqttd_cli:load(),
register_acl_mod(),
emqttd_plugins:init(),
emqttd_plugins:load(),
init_cluster(),
cluster_bootstrap(),
start_listeners(),
register(emqttd, self()),
print_vsn(),
@ -148,12 +148,16 @@ register_acl_mod() ->
end.
%%--------------------------------------------------------------------
%% Init Cluster
%% Cluster bootstrap
%%--------------------------------------------------------------------
init_cluster() ->
cluster_bootstrap() ->
ekka:callback(prepare, fun emqttd:shutdown/1),
ekka:callback(reboot, fun emqttd:reboot/0).
ekka:callback(reboot, fun emqttd:reboot/0),
run_outside_application(5000, fun ekka_autocluster:bootstrap/0).
run_outside_application(Delay, Fun) ->
spawn(fun() -> group_leader(whereis(init), self()), timer:sleep(Delay), Fun() end).
%%--------------------------------------------------------------------
%% Start Listeners

View File

@ -218,7 +218,7 @@ stop() -> gen_server:call(?ROUTER, stop).
init([]) ->
ekka:monitor(membership),
ets:new(mqtt_local_route, [set, named_table, protected]),
{ok, TRef} = timer:send_interval(timer:seconds(1), stats),
{ok, TRef} = timer:send_interval(timer:seconds(1), stats),
{ok, #state{stats_timer = TRef}}.
handle_call(stop, _From, State) ->