You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2008/06/15 20:02:54 UTC
svn commit: r667984 - in
/incubator/couchdb/branches/runtimeconfig/src/couchdb: couch_config.erl
couch_server_sup.erl
Author: jan
Date: Sun Jun 15 11:02:53 2008
New Revision: 667984
URL: http://svn.apache.org/viewvc?rev=667984&view=rev
Log:
Clean up code
Made couch_config:dump() a little prettier
Modified:
incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_config.erl
incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_server_sup.erl
Modified: incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_config.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_config.erl?rev=667984&r1=667983&r2=667984&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_config.erl (original)
+++ incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_config.erl Sun Jun 15 11:02:53 2008
@@ -32,6 +32,7 @@
dump/0, init_value/2, unset/1, load_ini_file/1,
load_ini_files/1]).
+-define(COUCH_CONFIG_CALLBACK, "_CouchDBConfigChangeCallback").
%% Public API %%
%% @type etstable() = integer().
@@ -192,12 +193,20 @@
%% @doc See dump/0
handle_call({dump, []}, _From, Tab) ->
- io:format("~p~n", [ets:match(Tab, '$1')]),
+ Config = lists:sort(ets:match(Tab, '$1')),
+ lists:foreach(fun([{{Module, Variable}, Value}]) ->
+ case Module of
+ ?COUCH_CONFIG_CALLBACK ->
+ ok; % ignore
+ _ ->
+ io:format("[~s] ~s=~p~n", [Module, Variable, Value])
+ end
+ end, Config),
{reply, ok, Tab};
%% @doc See register/2
handle_call({register, Key, Fun}, From, Tab) ->
- ets:insert(Tab, {{"_CouchDB", Key}, {From, Fun}}),
+ ets:insert(Tab, {{?COUCH_CONFIG_CALLBACK, Key}, {From, Fun}}),
{reply, ok, Tab}.
%% @spec notify_registered_modules(
@@ -208,9 +217,9 @@
notify_registered_modules(Tab, {{Module, Variable}, _Value}) ->
% look for processes that registered for notifications for
% specific configuration variables
- case ets:lookup(Tab, {"_CouchDB", {Module, Variable}}) of
+ case ets:lookup(Tab, {?COUCH_CONFIG_CALLBACK, {Module, Variable}}) of
% found
- [{{"_CouchDB", {Module, Variable}}, {_From, Fun}}] ->
+ [{{?COUCH_CONFIG_CALLBACK, {Module, Variable}}, {_From, Fun}}] ->
Fun();
_ -> % not found
ok
@@ -218,9 +227,9 @@
% look for processes that registerd for notifications for
% entire modules. Their "Variable" value will be the empty string
- case ets:lookup(Tab, {"_CouchDB", {Module, ""}}) of
+ case ets:lookup(Tab, {?COUCH_CONFIG_CALLBACK, {Module, ""}}) of
% found
- [{{"_CouchDB", {Module, _Variable}}, {_From2, Fun2}}] ->
+ [{{?COUCH_CONFIG_CALLBACK, {Module, _Variable}}, {_From2, Fun2}}] ->
Fun2();
_ -> % not found
ok
Modified: incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_server_sup.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_server_sup.erl?rev=667984&r1=667983&r2=667984&view=diff
==============================================================================
--- incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_server_sup.erl (original)
+++ incubator/couchdb/branches/runtimeconfig/src/couchdb/couch_server_sup.erl Sun Jun 15 11:02:53 2008
@@ -41,6 +41,15 @@
_ -> ok
end,
+ % annoucne startup
+ io:format("Apache CouchDB ~s (LogLevel=~s)~n", [
+ couch_server:get_version(),
+ couch_config:lookup({"Log", "Level"})
+ ]),
+
+ io:format("~s~n~n", [couch_config:lookup({"CouchDB", "StartupMessage"})]),
+
+
% read config and register for configuration changes
% just stop if one of the config settings change. couch_server_sup
@@ -73,12 +82,6 @@
brutal_kill,
worker,
[couch_server]},
- % {couch_util,
- % {couch_util, start_link, []},
- % permanent,
- % brutal_kill,
- % worker,
- % [couch_util]},
{couch_query_servers,
{couch_query_servers, start_link, []},
permanent,
@@ -119,14 +122,8 @@
[couch_ft_query]}]
end,
- io:format("Apache CouchDB ~s (LogLevel=~s)~n", [
- couch_server:get_version(),
- couch_config:lookup({"Log", "Level"})
- ]),
-
- io:format("~s~n~n", [couch_config:lookup({"CouchDB", "StartupMessage"})]),
-
- ok = couch_util:start_driver(),
+ % launch the icu bridge
+ couch_util:start_driver(),
% ensure these applications are running
application:start(inets),
@@ -154,32 +151,4 @@
couch_log:stop().
init(ChildProcesses) ->
- {ok, {{one_for_one, 10, 3600}, ChildProcesses}}.
-
-% dump_config() ->
-% io:format("Debug: ~p~n", [dying]),
-% ?LOG_DEBUG("~s", [okay]).
-% % {ok, Cwd} = file:get_cwd(),
-% % ConfigInfo = io_lib:format("Config Info:~n\tCurrentWorkingDir=~s~n" ++
-% % "\tDbRootDir=~s~n" ++
-% % "\tBindAddress=~p~n" ++
-% % "\tPort=~p~n" ++
-% % "\tDocumentRoot=~s~n" ++
-% % "\tLogFile=~s~n" ++
-% % "\tLogLevel=~s~n" ++
-% % "\tUtilDriverDir=~s~n" ++
-% % "\tDbUpdateNotificationProcesses=~s~n" ++
-% % "\tFullTextSearchQueryServer=~s~n" ++
-% % "~s",
-% % [Cwd,
-% % couch_config:lookup({couchdb, root_directory}),
-% % couch_config:lookup({couchdb, util_driver_dir}),
-% % couch_config:lookup({couchdb, update_notification_processes}),
-% % couch_config:lookup({httpd, bind_address}),
-% % couch_config:lookup({httpd, port}),
-% % couch_config:lookup({httpd, document_root}),
-% % couch_config:lookup({log, file}),
-% % couch_config:lookup({log, level}),
-% % couch_config:lookup({fulltext, query_server}),
-% % [lists:flatten(io_lib:format("\t~s=~s~n", [Lang, QueryExe])) || {Lang, QueryExe} <- couch_config:lookup({couchdb, view_query_servers})]]),
-% % ?LOG_INFO("~s", [ConfigInfo]).
+ {ok, {{one_for_one, 10, 3600}, ChildProcesses}}.
\ No newline at end of file