From 90760d10d14c11ee4c99826163c206bbf20a77f6 Mon Sep 17 00:00:00 2001 From: Magnus Ahltorp Date: Thu, 24 Sep 2015 16:38:03 +0200 Subject: Change perm interface to be add/commit based --- src/plop_sup.erl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/plop_sup.erl') diff --git a/src/plop_sup.erl b/src/plop_sup.erl index 87316f4..442eabc 100644 --- a/src/plop_sup.erl +++ b/src/plop_sup.erl @@ -26,9 +26,24 @@ permanent_worker(Name, StartFunc, Modules) -> 10000, worker, Modules}. +perm_database_children(DB) -> + lists:filtermap(fun ({Name, DBName, ConfigName}) -> + case application:get_env(plop, ConfigName) of + {ok, Path} -> + {true, permanent_worker(Name, {perm, start_link, [DBName, Path]})}; + undefined -> + false + end + end, DB). + %% Supervisor callback init([]) -> Services = application:get_env(plop, services, []), + DBChildren = perm_database_children([ + {the_entryhash_db, entryhash_db, entryhash_root_path}, + {the_indexforhash_db, indexforhash_db, indexforhash_root_path}, + {the_entry_db, entry_db, entry_root_path} + ]), Children = [permanent_worker(the_db, {db, start_link, []}, [db]), permanent_worker(the_storagedb, {storagedb, start_link, []}), permanent_worker(fsync, {fsyncport, start_link, []})], @@ -41,5 +56,5 @@ init([]) -> end end, Services), {ok, {{one_for_one, 3, 10}, - Children ++ OptionalChildren + DBChildren ++ Children ++ OptionalChildren }}. -- cgit v1.1