You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2008/09/13 22:25:12 UTC

svn commit: r695024 - in /incubator/couchdb/trunk: etc/couchdb/default.ini.tpl.in src/couchdb/couch_server_sup.erl

Author: damien
Date: Sat Sep 13 13:25:11 2008
New Revision: 695024

URL: http://svn.apache.org/viewvc?rev=695024&view=rev
Log:
Moved most of the startup services from being hard coded in couch_server_sup to being loaded from the ini file.

Modified:
    incubator/couchdb/trunk/etc/couchdb/default.ini.tpl.in
    incubator/couchdb/trunk/src/couchdb/couch_server_sup.erl

Modified: incubator/couchdb/trunk/etc/couchdb/default.ini.tpl.in
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/etc/couchdb/default.ini.tpl.in?rev=695024&r1=695023&r2=695024&view=diff
==============================================================================
--- incubator/couchdb/trunk/etc/couchdb/default.ini.tpl.in (original)
+++ incubator/couchdb/trunk/etc/couchdb/default.ini.tpl.in Sat Sep 13 13:25:11 2008
@@ -19,3 +19,10 @@
 
 [query_servers]
 javascript = %bindir%/%couchjs_command_name% %localdatadir%/server/main.js
+
+[daemons]
+view_manager={couch_view, start_link, []}
+db_update_notifier={couch_db_update_notifier_sup, start_link, []}
+full_text_query={couch_ft_query, start_link, []}
+query_servers={couch_query_servers, start_link, []}
+httpd={couch_httpd, start_link, []}

Modified: incubator/couchdb/trunk/src/couchdb/couch_server_sup.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_server_sup.erl?rev=695024&r1=695023&r2=695024&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_server_sup.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_server_sup.erl Sat Sep 13 13:25:11 2008
@@ -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 @@
     
     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 @@
             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 @@
     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 @@
                 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).