From 3751c13253370c72735fb070588fa8d99db5e81a Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Sat, 30 Aug 2008 14:27:01 +0000 Subject: - Rename configuration options and sections to allow for a nicer .ini file and HTTP API calls. - Enable .ini parser to read variable assignments with spaces around the '='-sign. - Remove inadequate comment. git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@690513 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_config.erl | 2 +- src/couchdb/couch_config_writer.erl | 4 ++-- src/couchdb/couch_ft_query.erl | 4 ++-- src/couchdb/couch_httpd.erl | 12 ++++++------ src/couchdb/couch_log.erl | 8 ++++---- src/couchdb/couch_query_servers.erl | 6 +++--- src/couchdb/couch_server.erl | 12 ++++++------ src/couchdb/couch_server_sup.erl | 6 +++--- src/couchdb/couch_util.erl | 2 -- src/couchdb/couch_view.erl | 4 ++-- 10 files changed, 29 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/couchdb/couch_config.erl b/src/couchdb/couch_config.erl index c8c803fe..48386949 100644 --- a/src/couchdb/couch_config.erl +++ b/src/couchdb/couch_config.erl @@ -161,7 +161,7 @@ load_ini_file(IniFile) -> ";" ++ _Comment -> {AccSectionName, AccValues}; Line2 -> - case regexp:split(Line2, "=") of + case regexp:split(Line2, "\s?=\s?") of {ok, [_SingleElement]} -> % no "=" found, ignore this line {AccSectionName, AccValues}; {ok, [""|_LineValues]} -> % line begins with "=", ignore diff --git a/src/couchdb/couch_config_writer.erl b/src/couchdb/couch_config_writer.erl index 6a56c96e..561fd6c2 100644 --- a/src/couchdb/couch_config_writer.erl +++ b/src/couchdb/couch_config_writer.erl @@ -29,7 +29,7 @@ %% @doc Saves a Module/Key/Value triple to the ini file File::filename() save_to_file({{Module, Variable}, Value}, File) -> - ?LOG_DEBUG("saving to file '~s', Congif: '~p'", [File, {{Module, Variable}, Value}]), + ?LOG_DEBUG("saving to file '~s', Config: '~p'", [File, {{Module, Variable}, Value}]), % open file and create a list of lines {ok, Stream} = file:read_file(File), @@ -84,7 +84,7 @@ save_loop({{Module, Variable}, Value}, [Line|Rest], OldCurrentModule, Contents, case lists:member(Variable, DoneVariables) of false -> DoneVariables2 = [Variable|DoneVariables], - Variable ++ "=" ++ Value ++ "\n" ++ Line; + Variable ++ " = " ++ Value ++ "\n" ++ Line; true -> DoneVariables2 = DoneVariables, Line diff --git a/src/couchdb/couch_ft_query.erl b/src/couchdb/couch_ft_query.erl index 67fa5948..9f876794 100644 --- a/src/couchdb/couch_ft_query.erl +++ b/src/couchdb/couch_ft_query.erl @@ -28,11 +28,11 @@ execute(DatabaseName, QueryString) -> init([]) -> ok = couch_config:register( - fun({"Search", "QueryServer"}) -> + fun({"search", "query_server"}) -> ?MODULE:stop() end), - case couch_config:get({"Search", "QueryServer"}, none) of + case couch_config:get({"search", "query_server"}, none) of none -> {ok, none}; QueryExec -> diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index 1d420ffc..1e5551e6 100644 --- a/src/couchdb/couch_httpd.erl +++ b/src/couchdb/couch_httpd.erl @@ -44,9 +44,9 @@ start_link() -> % just stop if one of the config settings change. couch_server_sup % will restart us and then we will pick up the new settings. - BindAddress = couch_config:get({"HTTPd", "BindAddress"}, any), - Port = couch_config:get({"HTTPd", "Port"}, "5984"), - DocumentRoot = couch_config:get({"HTTPd", "DocumentRoot"}, "../../share/www"), + BindAddress = couch_config:get({"httpd", "bind_address"}, any), + Port = couch_config:get({"httpd", "port"}, "5984"), + DocumentRoot = couch_config:get({"httpd", "utils_dir"}, "../../share/www"), % and off we go Loop = fun (Req) -> apply(couch_httpd, handle_request, [Req, DocumentRoot]) end, @@ -57,11 +57,11 @@ start_link() -> {port, Port} ]), ok = couch_config:register( - fun({"HTTPd", "BindAddress"}) -> + fun({"httpd", "bind_address"}) -> ?MODULE:stop(); - ({"HTTPd", "Port"}) -> + ({"httpd", "port"}) -> ?MODULE:stop(); - ({"HTTPd", "DocumentRoot"}) -> + ({"httpd", "utils_dir"}) -> ?MODULE:stop() end, Pid), diff --git a/src/couchdb/couch_log.erl b/src/couchdb/couch_log.erl index 0c2f9df7..69dabbcf 100644 --- a/src/couchdb/couch_log.erl +++ b/src/couchdb/couch_log.erl @@ -46,14 +46,14 @@ init([]) -> % 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({"Log", "File"}) -> + fun({"log", "file"}) -> ?MODULE:stop(); - ({"Log", "Level"}) -> + ({"log", "level"}) -> ?MODULE:stop() end), - Filename = couch_config:get({"Log", "File"}, "couchdb.log"), - Level = couch_config:get({"Log", "Level"},"info"), + Filename = couch_config:get({"log", "file"}, "couchdb.log"), + Level = couch_config:get({"log", "level"},"info"), {ok, Fd} = file:open(Filename, [append]), {ok, {Fd, level_integer(list_to_atom(Level))}}. diff --git a/src/couchdb/couch_query_servers.erl b/src/couchdb/couch_query_servers.erl index 0160e8c7..ad207a63 100644 --- a/src/couchdb/couch_query_servers.erl +++ b/src/couchdb/couch_query_servers.erl @@ -36,7 +36,7 @@ readline(Port, Acc) -> case get(query_server_timeout) of undefined -> Timeout = list_to_integer(couch_config:get( - {"CouchDB Query Server Options", "QueryTimeout"}, "5000")), + {"couchdb", "view_timeout"}, "5000")), put(timeout, Timeout); Timeout -> ok end, @@ -178,12 +178,12 @@ init([]) -> % will restart us and then we will pick up the new settings. ok = couch_config:register( - fun({"CouchDB Query Server" ++ _, _}) -> + fun({"query_servers" ++ _, _}) -> ?MODULE:stop() end), QueryServerList = couch_config:lookup_match( - {{"CouchDB Query Servers", '$1'}, '$2'}, []), + {{"query_servers", '$1'}, '$2'}, []), {ok, {QueryServerList, []}}. diff --git a/src/couchdb/couch_server.erl b/src/couchdb/couch_server.erl index 2844b443..b6969f42 100644 --- a/src/couchdb/couch_server.erl +++ b/src/couchdb/couch_server.erl @@ -30,7 +30,7 @@ }). start() -> - start(["couch.ini"]). + start(["default.ini"]). start(IniFiles) -> couch_server_sup:start_link(IniFiles). @@ -94,13 +94,13 @@ init([]) -> % just stop if one of the config settings change. couch_server_sup % will restart us and then we will pick up the new settings. - RootDir = couch_config:get({"CouchDB", "RootDirectory"}, "."), - MaxDbsOpen = couch_config:get({"CouchDB", "MaxDbsOpen"}, "100"), + RootDir = couch_config:get({"couchdb", "database_dir"}, "."), + MaxDbsOpen = couch_config:get({"couchdb", "max_open_databases"}, "100"), Self = self(), ok = couch_config:register( - fun({"CouchDB", "RootDirectory"}) -> + fun({"couchdb", "database_dir"}) -> exit(Self, config_change); - ({"CouchDB", "ServerOptions"}) -> + ({"couchdb", "server_options"}) -> exit(Self, config_change) end), {ok, RegExp} = regexp:parse("^[a-z][a-z0-9\\_\\$()\\+\\-\\/]*$"), @@ -261,7 +261,7 @@ handle_call({delete, DbName}, _From, Server) -> {reply, Error, Server} end; handle_call(remote_restart, _From, Server) -> - case couch_config:get({"CouchDB", "AllowRemoteRestart"}, "false") of + case couch_config:get({"couchdb", "allow_remote_restart"}, "false") of "true" -> exit(couch_server_sup, restart); _ -> diff --git a/src/couchdb/couch_server_sup.erl b/src/couchdb/couch_server_sup.erl index b90ec07e..b34db356 100644 --- a/src/couchdb/couch_server_sup.erl +++ b/src/couchdb/couch_server_sup.erl @@ -49,7 +49,7 @@ start_server(IniFiles) -> {ok, ConfigPid} = couch_config:start_link(IniFiles), - LogLevel = couch_config:get({"Log", "Level"}, "info"), + LogLevel = couch_config:get({"log", "level"}, "info"), % announce startup io:format("Apache CouchDB ~s (LogLevel=~s) is starting.~n", [ couch_server:get_version(), @@ -64,7 +64,7 @@ start_server(IniFiles) -> end, LibDir = - case couch_config:get({"CouchDB", "UtilDriverDir"}, null) of + case couch_config:get({"couchdb", "util_driver_dir"}, null) of null -> filename:join(code:priv_dir(couch), "lib"); LibDir0 -> LibDir0 @@ -100,7 +100,7 @@ start_server(IniFiles) -> % just restart if one of the config settings change. couch_config:register( - fun({"CouchDB", "UtilDriverDir"}) -> + fun({"couchdb", "util_driver_dir"}) -> ?MODULE:stop() end, Pid), diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl index 647d4d6e..4db10332 100644 --- a/src/couchdb/couch_util.erl +++ b/src/couchdb/couch_util.erl @@ -23,8 +23,6 @@ -define(FLUSH_MAX_MEM, 10000000). start_driver(LibDir) -> - % read config and register for configuration changes - case erl_ddll:load_driver(LibDir, "couch_erl_driver") of ok -> ok; diff --git a/src/couchdb/couch_view.erl b/src/couchdb/couch_view.erl index ec6b16cf..938084df 100644 --- a/src/couchdb/couch_view.erl +++ b/src/couchdb/couch_view.erl @@ -222,10 +222,10 @@ fold(#view{btree=Btree}, StartKey, Dir, Fun, Acc) -> init([]) -> % read configuration settings and register for configuration changes - RootDir = couch_config:get({"CouchDB", "RootDirectory"}), + RootDir = couch_config:get({"couchdb", "database_dir"}), Self = self(), ok = couch_config:register( - fun({"CouchDB", "RootDirectory"})-> + fun({"couchdb", "database_dir"})-> exit(Self, config_change) end), -- cgit v1.2.3