summaryrefslogtreecommitdiff
path: root/src/plop_sup.erl
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2015-09-24 16:38:03 +0200
committerLinus Nordberg <linus@nordu.net>2015-11-11 13:32:36 +0100
commit90760d10d14c11ee4c99826163c206bbf20a77f6 (patch)
tree5965c6bb108538507464d98595cc631dd9441aa7 /src/plop_sup.erl
parent346a3f973b828abc21cffb8a0a976daddcabe492 (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
}}.