summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2019-05-21 10:28:15 +0200
committerJan Lehnardt <jan@apache.org>2019-05-21 10:28:15 +0200
commit4e78cafcd22e5931dce6fc5df2a0f457098581e7 (patch)
tree3e7db6aa84225abc2698eab2a4ee3f10e1e430ba
parent5d3c2fb398292f079c29553ce15d85237833e7fd (diff)
downloadcouchdb-fix/cleanup-config.tar.gz
feat: move fauxton docroot config to OS env-vars for consistencyfix/cleanup-config
-rwxr-xr-xdev/run14
-rwxr-xr-xrel/files/couchdb.in1
-rw-r--r--rel/overlay/etc/default.ini1
-rw-r--r--src/chttpd/src/chttpd_misc.erl9
4 files changed, 16 insertions, 9 deletions
diff --git a/dev/run b/dev/run
index fec7d7355..60e7d5c35 100755
--- a/dev/run
+++ b/dev/run
@@ -249,11 +249,6 @@ def check_beams(ctx):
@log("Prepare configuration files")
def setup_configs(ctx):
- if os.path.exists("src/fauxton/dist/release"):
- fauxton_root = "src/fauxton/dist/release"
- else:
- fauxton_root = "share/www"
-
for idx, node in enumerate(ctx["nodes"]):
cluster_port, backend_port = get_ports(ctx, idx + ctx["node_number"])
env = {
@@ -268,7 +263,6 @@ def setup_configs(ctx):
"node_name": "-name %s@127.0.0.1" % node,
"cluster_port": cluster_port,
"backend_port": backend_port,
- "fauxton_root": fauxton_root,
"uuid": "fake_uuid_for_dev",
"_default": "",
}
@@ -530,6 +524,14 @@ def check_node_alive(url):
def set_boot_env(ctx):
+ # fudge fauxton path
+ if os.path.exists("src/fauxton/dist/release"):
+ fauxton_root = "src/fauxton/dist/release"
+ else:
+ fauxton_root = "share/www"
+
+ os.environ["COUCHDB_FAUXTON_DOCROOT"] = fauxton_root
+
# fudge default query server paths
couchjs = os.path.join(ctx["rootdir"], "src", "couch", "priv", "couchjs")
mainjs = os.path.join(ctx["rootdir"], "share", "server", "main.js")
diff --git a/rel/files/couchdb.in b/rel/files/couchdb.in
index aae179aa7..f4416115a 100755
--- a/rel/files/couchdb.in
+++ b/rel/files/couchdb.in
@@ -28,6 +28,7 @@ export PROGNAME=`echo $0 | sed 's/.*\///'`
export COUCHDB_QUERY_SERVER_JAVASCRIPT="{{prefix}}/bin/couchjs {{prefix}}/share/server/main.js"
export COUCHDB_QUERY_SERVER_COFFEESCRIPT="{{prefix}}/bin/couchjs {{prefix}}/share/server/main-coffee.js"
+export COUCHDB_FAUXTON_DOCROOT={{fauxton_root}}
ARGS_FILE="${COUCHDB_ARGS_FILE:-$ROOTDIR/etc/vm.args}"
SYSCONFIG_FILE="${COUCHDB_SYSCONFIG_FILE:-$ROOTDIR/releases/$APP_VSN/sys.config}"
diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini
index 2a920092f..0d7ac6d77 100644
--- a/rel/overlay/etc/default.ini
+++ b/rel/overlay/etc/default.ini
@@ -94,7 +94,6 @@ n=3
port = {{cluster_port}}
bind_address = 127.0.0.1
backlog = 512
-docroot = {{fauxton_root}}
socket_options = [{sndbuf, 262144}, {nodelay, true}]
server_options = [{recbuf, undefined}]
require_valid_user = false
diff --git a/src/chttpd/src/chttpd_misc.erl b/src/chttpd/src/chttpd_misc.erl
index 5aa9aaf97..819d7820e 100644
--- a/src/chttpd/src/chttpd_misc.erl
+++ b/src/chttpd/src/chttpd_misc.erl
@@ -63,7 +63,7 @@ handle_welcome_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
handle_favicon_req(Req) ->
- handle_favicon_req(Req, config:get("chttpd", "docroot")).
+ handle_favicon_req(Req, get_docroot()).
handle_favicon_req(#httpd{method='GET'}=Req, DocumentRoot) ->
{DateNow, TimeNow} = calendar:universal_time(),
@@ -80,7 +80,7 @@ handle_favicon_req(Req, _) ->
send_method_not_allowed(Req, "GET,HEAD").
handle_utils_dir_req(Req) ->
- handle_utils_dir_req(Req, config:get("chttpd", "docroot")).
+ handle_utils_dir_req(Req, get_docroot()).
handle_utils_dir_req(#httpd{method='GET'}=Req, DocumentRoot) ->
"/" ++ UrlPath = chttpd:path(Req),
@@ -504,3 +504,8 @@ message_queues(Registered) ->
{Type, Length} = process_info(whereis(Name), Type),
{Name, Length}
end, Registered).
+
+get_docroot() ->
+ % if the env var isn’t set, let’s not throw an error, but
+ % assume the current working dir is what we want
+ os:getenv("COUCHDB_FAUXTON_DOCROOT", "").