summaryrefslogtreecommitdiff
path: root/src/plop_sup.erl
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-09-24 16:38:03 +0200
committerMagnus Ahltorp <map@kth.se>2015-09-24 16:38:03 +0200
commit47739f3a75b247db446eb863ab6d83d6ca461634 (patch)
tree36a07c625e37107ca2f35200ccc444cb6e210a0a /src/plop_sup.erl
parentcdd2d16b4acd17ab74cd0610857d07a547f052ab (diff)
Change perm interface to be add/commit based
Diffstat (limited to 'src/plop_sup.erl')
-rw-r--r--src/plop_sup.erl17
1 files changed, 16 insertions, 1 deletions
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
}}.