diff options
author | Robert Newson <rnewson@apache.org> | 2011-04-21 12:25:51 +0000 |
---|---|---|
committer | Robert Newson <rnewson@apache.org> | 2011-04-21 12:25:51 +0000 |
commit | 7abfc073e9332cf73dd03c05b8a32aba32236fcf (patch) | |
tree | 1c45467ae71809f813aa14ab44edb75684d95407 /src/couchdb | |
parent | 55aa33cb2cb6634c49812ce7c51171c8c45fbe2a (diff) |
print https address if enabled. add to URI file also.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1095678 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r-- | src/couchdb/couch_server_sup.erl | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/couchdb/couch_server_sup.erl b/src/couchdb/couch_server_sup.erl index 4f0445da..fafd83ed 100644 --- a/src/couchdb/couch_server_sup.erl +++ b/src/couchdb/couch_server_sup.erl @@ -119,15 +119,23 @@ start_server(IniFiles) -> unlink(ConfigPid), Ip = couch_config:get("httpd", "bind_address"), - Port = mochiweb_socket_server:get(couch_httpd, port), io:format("Apache CouchDB has started. Time to relax.~n"), - ?LOG_INFO("Apache CouchDB has started on http://~s:~w/", [Ip, Port]), - + Uris = [get_uri(Name, Ip) || Name <- [couch_httpd, https]], + [begin + case Uri of + undefined -> ok; + Uri -> ?LOG_INFO("Apache CouchDB has started on ~s", [Uri]) + end + end + || Uri <- Uris], case couch_config:get("couchdb", "uri_file", null) of null -> ok; UriFile -> - Line = io_lib:format("http://~s:~w/~n", [Ip, Port]), - file:write_file(UriFile, Line) + Lines = [begin case Uri of + undefined -> []; + Uri -> io_lib:format("~s~n", [Uri]) + end end || Uri <- Uris], + file:write_file(UriFile, Lines) end, {ok, Pid}. @@ -191,3 +199,22 @@ stop() -> init(ChildSpecs) -> {ok, ChildSpecs}. + +get_uri(Name, Ip) -> + case get_port(Name) of + undefined -> + undefined; + Port -> + io_lib:format("~s://~s:~w/", [get_scheme(Name), Ip, Port]) + end. + +get_scheme(couch_httpd) -> "http"; +get_scheme(https) -> "https". + +get_port(Name) -> + try + mochiweb_socket_server:get(Name, port) + catch + exit:{noproc, _}-> + undefined + end. |