summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_server_sup.erl
diff options
context:
space:
mode:
authorDamien F. Katz <damien@apache.org>2008-09-13 20:25:11 +0000
committerDamien F. Katz <damien@apache.org>2008-09-13 20:25:11 +0000
commit87476b2eba463f6aa406fbfe2257be7a5e765a1e (patch)
tree25d2eea1a30187bb78d34f880568f785112cbed1 /src/couchdb/couch_server_sup.erl
parent17ed6b64e900c9f20cf6288faa4b400ad8bd263e (diff)
Moved most of the startup services from being hard coded in couch_server_sup to being loaded from the ini file.
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@695024 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_server_sup.erl')
-rw-r--r--src/couchdb/couch_server_sup.erl66
1 files changed, 32 insertions, 34 deletions
diff --git a/src/couchdb/couch_server_sup.erl b/src/couchdb/couch_server_sup.erl
index 78ae13ed..23004e74 100644
--- a/src/couchdb/couch_server_sup.erl
+++ b/src/couchdb/couch_server_sup.erl
@@ -14,7 +14,7 @@
-behaviour(supervisor).
--export([start_link/1,stop/0,couch_config_start_link_wrapper/2,start_primary_services/0]).
+-export([start_link/1,stop/0,couch_config_start_link_wrapper/2,start_primary_services/0,start_secondary_services/0]).
-include("couch_db.hrl").
@@ -72,7 +72,7 @@ start_server(IniFiles) ->
ok = couch_util:start_driver(LibDir),
- BaseServices =
+ BaseChildSpecs =
{{one_for_all, 10, 3600},
[{couch_config,
{couch_server_sup, couch_config_start_link_wrapper, [IniFiles, ConfigPid]},
@@ -85,6 +85,12 @@ start_server(IniFiles) ->
permanent,
infinity,
supervisor,
+ [couch_server_sup]},
+ {couch_secondary_services,
+ {couch_server_sup, start_secondary_services, []},
+ permanent,
+ infinity,
+ supervisor,
[couch_server_sup]}
]},
@@ -94,13 +100,15 @@ start_server(IniFiles) ->
application:start(crypto),
{ok, Pid} = supervisor:start_link(
- {local, couch_server_sup}, couch_server_sup, BaseServices),
+ {local, couch_server_sup}, couch_server_sup, BaseChildSpecs),
% launch the icu bridge
% just restart if one of the config settings change.
couch_config:register(
fun("couchdb", "util_driver_dir") ->
+ ?MODULE:stop();
+ ("daemons", _) ->
?MODULE:stop()
end, Pid),
@@ -119,48 +127,38 @@ start_primary_services() ->
brutal_kill,
worker,
[couch_log]},
- {couch_db_update_event,
- {gen_event, start_link, [{local, couch_db_update}]},
- permanent,
- brutal_kill,
- supervisor,
- dynamic},
{couch_server,
{couch_server, sup_start_link, []},
permanent,
brutal_kill,
supervisor,
[couch_server]},
- {couch_query_servers,
- {couch_query_servers, start_link, []},
- permanent,
- brutal_kill,
- supervisor,
- [couch_query_servers]},
- {couch_view,
- {couch_view, start_link, []},
- permanent,
- brutal_kill,
- supervisor,
- [couch_view]},
- {couch_httpd,
- {couch_httpd, start_link, []},
- permanent,
- brutal_kill,
- supervisor,
- [couch_httpd]},
- {couch_ft_query,
- {couch_ft_query, start_link, []},
+ {couch_db_update_event,
+ {gen_event, start_link, [{local, couch_db_update}]},
permanent,
brutal_kill,
supervisor,
- [couch_ft_query]},
- {couch_db_update_notifier_sup,
- {couch_db_update_notifier_sup, start_link, []},
+ dynamic}]}).
+
+
+start_secondary_services() ->
+ DaemonChildSpecs = [
+ begin
+ {ok, Tokens, _} = erl_scan:string(SpecStr ++ "."),
+ {ok, {Module, Fun, Args}} = erl_parse:parse_term(Tokens),
+
+ {list_to_atom(Name),
+ {Module, Fun, Args},
permanent,
brutal_kill,
- supervisor,
- [couch_db_update_notifier_sup]}]}).
+ worker,
+ [Module]}
+ end
+ || {Name, SpecStr}
+ <- couch_config:get("daemons"), SpecStr /= ""],
+
+ supervisor:start_link(couch_server_sup,
+ {{one_for_one, 10, 3600}, DaemonChildSpecs}).
stop() ->
catch exit(whereis(couch_server_sup), normal).