Return-Path: Delivered-To: apmail-incubator-couchdb-commits-archive@locus.apache.org Received: (qmail 691 invoked from network); 15 Jun 2008 18:03:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Jun 2008 18:03:45 -0000 Received: (qmail 26891 invoked by uid 500); 15 Jun 2008 18:03:47 -0000 Delivered-To: apmail-incubator-couchdb-commits-archive@incubator.apache.org Received: (qmail 26871 invoked by uid 500); 15 Jun 2008 18:03:47 -0000 Mailing-List: contact couchdb-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-dev@incubator.apache.org Delivered-To: mailing list couchdb-commits@incubator.apache.org Received: (qmail 26861 invoked by uid 99); 15 Jun 2008 18:03:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 15 Jun 2008 11:03:47 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 15 Jun 2008 18:03:06 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 70821238898F; Sun, 15 Jun 2008 11:02:54 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r667984 - in /incubator/couchdb/branches/runtimeconfig/src/couchdb: couch_config.erl couch_server_sup.erl Date: Sun, 15 Jun 2008 18:02:54 -0000 To: couchdb-commits@incubator.apache.org From: jan@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080615180254.70821238898F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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