diff options
author | Magnus Ahltorp <map@kth.se> | 2015-03-01 13:32:04 +0100 |
---|---|---|
committer | Magnus Ahltorp <map@kth.se> | 2015-03-01 13:32:04 +0100 |
commit | 985fd30939e9901ea2c7f82d747e975d4e4ed50a (patch) | |
tree | e9262388ca5a6bee0d805a26098e5ed6bb8dfd2b /src/plop_sup.erl | |
parent | 0aff0f752fd4a5d342fbb1a9a9192ae239f48b1f (diff) |
Make sign and ht optional processes. Move sign args to config.
Diffstat (limited to 'src/plop_sup.erl')
-rw-r--r-- | src/plop_sup.erl | 61 |
1 files changed, 28 insertions, 33 deletions
diff --git a/src/plop_sup.erl b/src/plop_sup.erl index eb65925..c125cc0 100644 --- a/src/plop_sup.erl +++ b/src/plop_sup.erl @@ -7,44 +7,39 @@ -export([start_link/1, init/1]). -export([start_in_shell/1]). -start_link(Args) -> - supervisor:start_link({local, ?MODULE}, ?MODULE, Args). +start_link(_Args) -> + supervisor:start_link({local, ?MODULE}, ?MODULE, []). %% For testing. start_in_shell(Args) -> {ok, Pid} = start_link(Args), unlink(Pid). + +permanent_worker(Name, {Module, Function, Args}) -> + permanent_worker(Name, {Module, Function, Args}, [Module]). + +permanent_worker(Name, StartFunc, Modules) -> + {Name, + StartFunc, + permanent, + 10000, + worker, Modules}. + %% Supervisor callback -init(Args) -> +init([]) -> + Services = application:get_env(plop, services, []), + Children = [permanent_worker(the_db, {db, start_link, []}, [db]), + permanent_worker(the_storagedb, {storagedb, start_link, []}), + permanent_worker(fsync, {fsyncport, start_link, []})], + OptionalChildren = lists:map(fun (ServiceName) -> + case ServiceName of + ht -> + permanent_worker(the_ht, {ht, start_link, []}); + sign -> + permanent_worker(the_signing, {sign, start_link, []}) + end + end, Services), {ok, {{one_for_one, 3, 10}, - [{the_db, - {db, start_link, []}, - permanent, - 10000, - worker, [db]}, - {the_storagedb, - {storagedb, start_link, []}, - permanent, - 10000, - worker, [storagedb]}, - {fsync, - {fsyncport, start_link, []}, - permanent, - 10000, - worker, [fsyncport]}, - {the_ht, - {ht, start_link, []}, - permanent, - 10000, - worker, [ht]}, - {the_signing, - {sign, start_link, Args}, % All arguments go to sign. - permanent, - 10000, - worker, [sign]}, - {the_plop, - {plop, start_link, []}, - permanent, - 10000, % Shut down within 10s. - worker, [plop]}]}}. + Children ++ OptionalChildren + }}. |