couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From beno...@apache.org
Subject svn commit: r1054624 - in /couchdb/trunk: etc/couchdb/ src/couchdb/
Date Mon, 03 Jan 2011 14:17:35 GMT
Author: benoitc
Date: Mon Jan  3 14:17:35 2011
New Revision: 1054624

URL: http://svn.apache.org/viewvc?rev=1054624&view=rev
Log:
rever changes in supervision tree & such.

Removed:
    couchdb/trunk/src/couchdb/couch_drv.erl
    couchdb/trunk/src/couchdb/couch_primary_sup.erl
    couchdb/trunk/src/couchdb/couch_secondary_sup.erl
Modified:
    couchdb/trunk/etc/couchdb/default.ini.tpl.in
    couchdb/trunk/src/couchdb/Makefile.am
    couchdb/trunk/src/couchdb/couch_db_update_notifier_sup.erl
    couchdb/trunk/src/couchdb/couch_external_manager.erl
    couchdb/trunk/src/couchdb/couch_query_servers.erl
    couchdb/trunk/src/couchdb/couch_server_sup.erl

Modified: couchdb/trunk/etc/couchdb/default.ini.tpl.in
URL: http://svn.apache.org/viewvc/couchdb/trunk/etc/couchdb/default.ini.tpl.in?rev=1054624&r1=1054623&r2=1054624&view=diff
==============================================================================
--- couchdb/trunk/etc/couchdb/default.ini.tpl.in (original)
+++ couchdb/trunk/etc/couchdb/default.ini.tpl.in Mon Jan  3 14:17:35 2011
@@ -51,6 +51,7 @@ os_process_limit = 25
 [daemons]
 view_manager={couch_view, start_link, []}
 external_manager={couch_external_manager, start_link, []}
+db_update_notifier={couch_db_update_notifier_sup, start_link, []}
 query_servers={couch_query_servers, start_link, []}
 httpd={couch_httpd, start_link, []}
 stats_aggregator={couch_stats_aggregator, start, []}

Modified: couchdb/trunk/src/couchdb/Makefile.am
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/Makefile.am?rev=1054624&r1=1054623&r2=1054624&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/Makefile.am (original)
+++ couchdb/trunk/src/couchdb/Makefile.am Mon Jan  3 14:17:35 2011
@@ -38,7 +38,6 @@ source_files = \
     couch_db_update_notifier.erl \
     couch_db_update_notifier_sup.erl \
     couch_doc.erl \
-    couch_drv.erl \
     couch_event_sup.erl \
     couch_external_manager.erl \
     couch_external_server.erl \
@@ -60,7 +59,6 @@ source_files = \
     couch_native_process.erl \
     couch_os_daemons.erl \
     couch_os_process.erl \
-    couch_primary_sup.erl \
     couch_query_servers.erl \
     couch_ref_counter.erl \
     couch_rep.erl \
@@ -72,7 +70,6 @@ source_files = \
     couch_rep_sup.erl \
     couch_rep_writer.erl \
     couch_rep_db_listener.erl \
-    couch_secondary_sup.erl \
     couch_server.erl \
     couch_server_sup.erl \
     couch_stats_aggregator.erl \
@@ -103,7 +100,6 @@ compiled_files = \
     couch_db_update_notifier.beam \
     couch_db_update_notifier_sup.beam \
     couch_doc.beam \
-    couch_drv.beam \
     couch_event_sup.beam \
     couch_external_manager.beam \
     couch_external_server.beam \
@@ -125,7 +121,6 @@ compiled_files = \
     couch_native_process.beam \
     couch_os_daemons.beam \
     couch_os_process.beam \
-    couch_primary_sup.beam \
     couch_query_servers.beam \
     couch_ref_counter.beam \
     couch_rep.beam \
@@ -137,7 +132,6 @@ compiled_files = \
     couch_rep_sup.beam \
     couch_rep_writer.beam \
     couch_rep_db_listener.beam \
-    couch_secondary_sup.beam \
     couch_server.beam \
     couch_server_sup.beam \
     couch_stats_aggregator.beam \

Modified: couchdb/trunk/src/couchdb/couch_db_update_notifier_sup.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db_update_notifier_sup.erl?rev=1054624&r1=1054623&r2=1054624&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db_update_notifier_sup.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db_update_notifier_sup.erl Mon Jan  3 14:17:35 2011
@@ -22,14 +22,16 @@
 
 -behaviour(supervisor).
 
--export([start_link/0, init/1, config_change/3]).
+-export([start_link/0,init/1]).
 
 start_link() ->
     supervisor:start_link({local, couch_db_update_notifier_sup},
         couch_db_update_notifier_sup, []).
 
 init([]) ->
-    ok = couch_config:register(fun ?MODULE:config_change/3),
+    ok = couch_config:register(
+        fun("update_notification", Key, Value) -> reload_config(Key, Value) end
+    ),
 
     UpdateNotifierExes = couch_config:get("update_notification"),
 
@@ -46,7 +48,7 @@ init([]) ->
 
 %% @doc when update_notification configuration changes, terminate the process
 %%      for that notifier and start a new one with the updated config
-config_change("update_notification", Id, Exe) ->
+reload_config(Id, Exe) ->
     ChildSpec = {
         Id,
         {couch_db_update_notifier, start_link, [Exe]},

Modified: couchdb/trunk/src/couchdb/couch_external_manager.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_external_manager.erl?rev=1054624&r1=1054623&r2=1054624&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_external_manager.erl (original)
+++ couchdb/trunk/src/couchdb/couch_external_manager.erl Mon Jan  3 14:17:35 2011
@@ -39,7 +39,7 @@ config_change("external", UrlName) ->
 init([]) ->
     process_flag(trap_exit, true),
     Handlers = ets:new(couch_external_manager_handlers, [set, private]),
-    couch_config:register(fun ?MODULE:config_change/2),
+    couch_config:register(fun config_change/2),
     {ok, Handlers}.
 
 terminate(_Reason, Handlers) ->

Modified: couchdb/trunk/src/couchdb/couch_query_servers.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_query_servers.erl?rev=1054624&r1=1054623&r2=1054624&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_query_servers.erl (original)
+++ couchdb/trunk/src/couchdb/couch_query_servers.erl Mon Jan  3 14:17:35 2011
@@ -13,7 +13,7 @@
 -module(couch_query_servers).
 -behaviour(gen_server).
 
--export([start_link/0, config_change/1]).
+-export([start_link/0]).
 
 -export([init/1, terminate/2, handle_call/3, handle_cast/2, handle_info/2,code_change/3]).
 -export([start_doc_map/3, map_docs/2, stop_doc_map/1]).
@@ -265,9 +265,26 @@ with_ddoc_proc(#doc{id=DDocId,revs={Star
     end.
 
 init([]) ->
-    % register async to avoid deadlock on restart_child
-    Self = self(),
-    spawn(couch_config, register, [fun ?MODULE:config_change/1, Self]),
+    % read config and register for configuration changes
+
+    % just stop if one of the config settings change. couch_server_sup
+    % will restart us and then we will pick up the new settings.
+
+    ok = couch_config:register(
+        fun("query_servers" ++ _, _) ->
+            supervisor:terminate_child(couch_secondary_services, query_servers),
+            supervisor:restart_child(couch_secondary_services, query_servers)
+        end),
+    ok = couch_config:register(
+        fun("native_query_servers" ++ _, _) ->
+            supervisor:terminate_child(couch_secondary_services, query_servers),
+            [supervisor:restart_child(couch_secondary_services, query_servers)]
+        end),
+    ok = couch_config:register(
+        fun("query_server_config" ++ _, _) ->
+            supervisor:terminate_child(couch_secondary_services, query_servers),
+            supervisor:restart_child(couch_secondary_services, query_servers)
+        end),
 
     Langs = ets:new(couch_query_server_langs, [set, private]),
     LangLimits = ets:new(couch_query_server_lang_limits, [set, private]),
@@ -377,16 +394,6 @@ handle_info({'EXIT', Pid, Status}, #qser
 code_change(_OldVsn, State, _Extra) ->
     {ok, State}.
 
-config_change("query_servers") ->
-    supervisor:terminate_child(couch_secondary_services, query_servers),
-    supervisor:restart_child(couch_secondary_services, query_servers);
-config_change("native_query_servers") ->
-    supervisor:terminate_child(couch_secondary_services, query_servers),
-    supervisor:restart_child(couch_secondary_services, query_servers);
-config_change("query_server_config") ->
-    supervisor:terminate_child(couch_secondary_services, query_servers),
-    supervisor:restart_child(couch_secondary_services, query_servers).
-
 % Private API
 
 add_to_waitlist(Info, From, #qserver{waitlist=Waitlist}=Server) ->

Modified: couchdb/trunk/src/couchdb/couch_server_sup.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_server_sup.erl?rev=1054624&r1=1054623&r2=1054624&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_server_sup.erl (original)
+++ couchdb/trunk/src/couchdb/couch_server_sup.erl Mon Jan  3 14:17:35 2011
@@ -7,7 +7,7 @@
 % Unless required by applicable law or agreed to in writing, software
 % distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 % WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-% License for the specific languag governing permissions and limitations under
+% License for the specific language governing permissions and limitations under
 % the License.
 
 -module(couch_server_sup).
@@ -15,7 +15,8 @@
 
 
 -export([start_link/1,stop/0, couch_config_start_link_wrapper/2,
-        restart_core_server/0, config_change/2]).
+        start_primary_services/0,start_secondary_services/0,
+        restart_core_server/0]).
 
 -include("couch_db.hrl").
 
@@ -67,6 +68,15 @@ start_server(IniFiles) ->
     _ -> ok
     end,
 
+    LibDir =
+    case couch_config:get("couchdb", "util_driver_dir", null) of
+    null ->
+        filename:join(couch_util:priv_dir(), "lib");
+    LibDir0 -> LibDir0
+    end,
+
+    ok = couch_util:start_driver(LibDir),
+
     BaseChildSpecs =
     {{one_for_all, 10, 3600},
         [{couch_config,
@@ -76,17 +86,17 @@ start_server(IniFiles) ->
             worker,
             [couch_config]},
         {couch_primary_services,
-            {couch_primary_sup, start_link, []},
+            {couch_server_sup, start_primary_services, []},
             permanent,
             infinity,
             supervisor,
-            [couch_primary_sup]},
+            [couch_server_sup]},
         {couch_secondary_services,
-            {couch_secondary_sup, start_link, []},
+            {couch_server_sup, start_secondary_services, []},
             permanent,
             infinity,
             supervisor,
-            [couch_secondary_sup]}
+            [couch_server_sup]}
         ]},
 
     % ensure these applications are running
@@ -96,8 +106,15 @@ start_server(IniFiles) ->
     {ok, Pid} = supervisor:start_link(
         {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 ?MODULE:config_change/2, Pid),
+
+    couch_config:register(
+        fun("couchdb", "util_driver_dir") ->
+            ?MODULE:stop();
+        ("daemons", _) ->
+            ?MODULE:stop()
+        end, Pid),
 
     unlink(ConfigPid),
 
@@ -115,12 +132,59 @@ start_server(IniFiles) ->
 
     {ok, Pid}.
 
-config_change("daemons", _) ->
-    exit(whereis(couch_server_sup), shutdown);
-config_change("couchdb", "util_driver_dir") ->
-    [Pid] = [P || {collation_driver,P,_,_}
-        <- supervisor:which_children(couch_primary_services)],
-    Pid ! reload_driver.
+start_primary_services() ->
+    supervisor:start_link({local, couch_primary_services}, couch_server_sup,
+        {{one_for_one, 10, 3600},
+            [{couch_log,
+                {couch_log, start_link, []},
+                permanent,
+                brutal_kill,
+                worker,
+                [couch_log]},
+            {couch_replication_supervisor,
+                {couch_rep_sup, start_link, []},
+                permanent,
+                infinity,
+                supervisor,
+                [couch_rep_sup]},
+            {couch_task_status,
+                {couch_task_status, start_link, []},
+                permanent,
+                brutal_kill,
+                worker,
+                [couch_task_status]},
+            {couch_server,
+                {couch_server, sup_start_link, []},
+                permanent,
+                1000,
+                worker,
+                [couch_server]},
+            {couch_db_update_event,
+                {gen_event, start_link, [{local, couch_db_update}]},
+                permanent,
+                brutal_kill,
+                worker,
+                dynamic}
+            ]
+        }).
+
+start_secondary_services() ->
+    DaemonChildSpecs = [
+        begin
+            {ok, {Module, Fun, Args}} = couch_util:parse_term(SpecStr),
+
+            {list_to_atom(Name),
+                {Module, Fun, Args},
+                permanent,
+                1000,
+                worker,
+                [Module]}
+        end
+        || {Name, SpecStr}
+        <- couch_config:get("daemons"), SpecStr /= ""],
+
+    supervisor:start_link({local, couch_secondary_services}, couch_server_sup,
+        {{one_for_one, 10, 3600}, DaemonChildSpecs}).
 
 stop() ->
     catch exit(whereis(couch_server_sup), normal).



Mime
View raw message