Add ability to start FLUs at application startup
This commit is contained in:
parent
517941aaaa
commit
14fc37bd0d
3 changed files with 22 additions and 5 deletions
|
@ -104,6 +104,14 @@ stop(Pid) ->
|
|||
ping(Pid) ->
|
||||
gen_server:call(Pid, {ping}, infinity).
|
||||
|
||||
%% @doc Set chain members list.
|
||||
%%
|
||||
%% NOTE: This implementation is a bit brittle, in that an author with
|
||||
%% higher rank may try to re-suggest the old membership list if it
|
||||
%% races with an author of lower rank. For now, we suggest calling
|
||||
%% set_chain_members() first on the author of highest rank and finish
|
||||
%% with lowest rank, i.e. name z* first, name a* last.
|
||||
|
||||
set_chain_members(Pid, MembersDict) ->
|
||||
gen_server:call(Pid, {set_chain_members, MembersDict}, infinity).
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
-behaviour(supervisor).
|
||||
|
||||
%% External API
|
||||
-export([start_flu_package/4, stop_flu_package/1]).
|
||||
-export([make_package_spec/4, start_flu_package/4, stop_flu_package/1]).
|
||||
%% Internal API
|
||||
-export([start_link/4,
|
||||
make_p_regname/1, make_mgr_supname/1, make_proj_supname/1]).
|
||||
|
@ -34,10 +34,13 @@
|
|||
%% Supervisor callbacks
|
||||
-export([init/1]).
|
||||
|
||||
start_flu_package(FluName, TcpPort, DataDir, Props) ->
|
||||
Spec = {FluName, {machi_flu_psup, start_link,
|
||||
make_package_spec(FluName, TcpPort, DataDir, Props) ->
|
||||
{FluName, {machi_flu_psup, start_link,
|
||||
[FluName, TcpPort, DataDir, Props]},
|
||||
permanent, 5000, supervisor, []},
|
||||
permanent, 5000, supervisor, []}.
|
||||
|
||||
start_flu_package(FluName, TcpPort, DataDir, Props) ->
|
||||
Spec = make_package_spec(FluName, TcpPort, DataDir, Props),
|
||||
{ok, _SupPid} = supervisor:start_child(machi_flu_sup, Spec).
|
||||
|
||||
stop_flu_package(FluName) ->
|
||||
|
|
|
@ -41,5 +41,11 @@ init([]) ->
|
|||
MaxRestarts = 1000,
|
||||
MaxSecondsBetweenRestarts = 3600,
|
||||
SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts},
|
||||
{ok, {SupFlags, []}}.
|
||||
|
||||
Ps = application:get_env(machi, initial_flus, []),
|
||||
FLU_specs = [machi_flu_psup:make_package_spec(FluName, TcpPort,
|
||||
DataDir, Props) ||
|
||||
{FluName, TcpPort, DataDir, Props} <- Ps],
|
||||
|
||||
{ok, {SupFlags, FLU_specs}}.
|
||||
|
||||
|
|
Loading…
Reference in a new issue