Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions dev/run
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,6 @@ def boot_haproxy(ctx):


def hack_default_ini(ctx, node, contents):
# Replace couchjs command
couchjs = os.path.join(ctx['rootdir'], "src", "couch", "priv", "couchjs")
mainjs = os.path.join(ctx['rootdir'], "share", "server", "main.js")
coffeejs = os.path.join(ctx['rootdir'], "share", "server", "main-coffee.js")

repl = toposixpath("javascript = %s %s" % (couchjs, mainjs))
contents = re.sub("(?m)^javascript.*$", repl, contents)

repl = toposixpath("coffeescript = %s %s" % (couchjs, coffeejs))
contents = re.sub("(?m)^coffeescript.*$", repl, contents)

if ctx['enable_erlang_views']:
contents = re.sub(
Expand Down Expand Up @@ -413,15 +403,29 @@ def check_node_alive(url):
if error is not None:
raise error

def set_boot_env(ctx):

# 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")
coffeejs = os.path.join(ctx['rootdir'], "share", "server", "main-coffee.js")

qs_javascript = toposixpath("%s %s" % (couchjs, mainjs))
qs_coffescript = toposixpath("%s %s" % (couchjs, coffeejs))

os.environ['COUCHDB_QUERY_SERVER_JAVASCRIPT'] = qs_javascript
os.environ['COUCHDB_QUERY_SERVER_COFFEESCRIPT'] = qs_coffescript

@log('Start node {node}')
def boot_node(ctx, node):
erl_libs = os.path.join(ctx['rootdir'], "src")
set_boot_env(ctx)
env = os.environ.copy()
env["ERL_LIBS"] = os.pathsep.join([erl_libs])

node_etcdir = os.path.join(ctx['devdir'], "lib", node, "etc")
reldir = os.path.join(ctx['rootdir'], "rel")

cmd = [
"erl",
"-args_file", os.path.join(node_etcdir, "vm.args"),
Expand Down
2 changes: 1 addition & 1 deletion rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ SubDirs = [

DepDescs = [
%% Independent Apps
{config, "config", {tag, "1.0.4"}},
{config, "config", {tag, "fix/conf"}},
{b64url, "b64url", {tag, "1.0.1"}},
{ets_lru, "ets-lru", {tag, "1.0.0"}},
{khash, "khash", {tag, "1.0.1"}},
Expand Down
3 changes: 3 additions & 0 deletions rel/overlay/bin/couchdb.cmd → rel/files/couchdb.cmd.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ set EMU=beam
set PROGNAME=%~n0
set PATH=%PATH%;%COUCHDB_BIN_DIR%

set COUCHDB_QUERY_SERVER_JAVASCRIPT="{{prefix}}/bin/couchjs {{prefix}}/share/server/main.js"
set COUCHDB_QUERY_SERVER_COFFEESCRIPT="{{prefix}}/bin/couchjs {{prefix}}/share/server/main-coffee.js"

"%BINDIR%\erl" -boot "%ROOTDIR%\releases\%APP_VSN%\couchdb" ^
-args_file "%ROOTDIR%\etc\vm.args" ^
-config "%ROOTDIR%\releases\%APP_VSN%\sys.config" %*
Expand Down
4 changes: 3 additions & 1 deletion rel/overlay/bin/couchdb → rel/files/couchdb.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ export BINDIR="$ROOTDIR/erts-$ERTS_VSN/bin"
export EMU=beam
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"

ARGS_FILE="${COUCHDB_ARGS_FILE:-$ROOTDIR/etc/vm.args}"
SYSCONFIG_FILE="${COUCHDB_SYSCONFIG_FILE:-$ROOTDIR/releases/$APP_VSN/sys.config}"

exec "$BINDIR/erlexec" -boot "$ROOTDIR/releases/$APP_VSN/couchdb" \
-args_file "${ARGS_FILE}" \
-config "${SYSCONFIG_FILE}" "$@"

55 changes: 2 additions & 53 deletions rel/overlay/etc/default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ database_prefix = userdb-
port = {{backend_port}}
bind_address = 127.0.0.1
authentication_handlers = {couch_httpd_auth, cookie_authentication_handler}, {couch_httpd_auth, default_authentication_handler}
default_handler = {couch_httpd_db, handle_request}
secure_rewrites = true
vhost_global_handlers = _utils, _uuids, _session, _users
allow_jsonp = false
; Options for the MochiWeb HTTP server.
;server_options = [{backlog, 128}, {acceptor_pool_size, 16}]
Expand Down Expand Up @@ -262,13 +260,9 @@ credentials = false
; List of hosts separated by a comma. * means accept all
; hosts =

[query_servers]
javascript = {{prefix}}/bin/couchjs {{prefix}}/share/server/main.js
coffeescript = {{prefix}}/bin/couchjs {{prefix}}/share/server/main-coffee.js

; enable mango query engine
[native_query_servers]
query = {mango_native_proc, start_link, []}
; erlang query server
; enable_erlang_query_server = false

; Changing reduce_limit to false will disable reduce_limit.
; If you think you're hitting reduce_limit with a "good" reduce function,
Expand All @@ -283,16 +277,6 @@ os_process_limit = 100
; "infinity" is also a valid configuration value.
;group_info_timeout = 5000

[daemons]
index_server={couch_index_server, start_link, []}
query_servers={couch_proc_manager, start_link, []}
vhosts={couch_httpd_vhost, start_link, []}
httpd={couch_httpd, start_link, []}
uuids={couch_uuids, start, []}
auth_cache={couch_auth_cache, start_link, []}
os_daemons={couch_os_daemons, start_link, []}
compaction_daemon={couch_compaction_daemon, start_link, []}

[mango]
; Set to true to disable the "index all fields" text index, which can lead
; to out of memory issues when users have documents with nested array fields.
Expand All @@ -303,41 +287,6 @@ compaction_daemon={couch_compaction_daemon, start_link, []}
[indexers]
couch_mrview = true

[httpd_global_handlers]
/ = {couch_httpd_misc_handlers, handle_welcome_req, <<"Welcome">>}
favicon.ico = {couch_httpd_misc_handlers, handle_favicon_req, "{{prefix}}/share/www"}

_utils = {couch_httpd_misc_handlers, handle_utils_dir_req, "{{prefix}}/share/www"}
_all_dbs = {couch_httpd_misc_handlers, handle_all_dbs_req}
_active_tasks = {couch_httpd_misc_handlers, handle_task_status_req}
_config = {couch_httpd_misc_handlers, handle_config_req}
_replicate = {couch_replicator_httpd, handle_req}
_uuids = {couch_httpd_misc_handlers, handle_uuids_req}
_stats = {couch_stats_httpd, handle_stats_req}
_session = {couch_httpd_auth, handle_session_req}
_plugins = {couch_plugins_httpd, handle_req}
_system = {chttpd_misc, handle_system_req}

[httpd_db_handlers]
_all_docs = {couch_mrview_http, handle_all_docs_req}
_local_docs = {couch_mrview_http, handle_local_docs_req}
_design_docs = {couch_mrview_http, handle_design_docs_req}
_changes = {couch_httpd_db, handle_db_changes_req}
_compact = {couch_httpd_db, handle_compact_req}
_design = {couch_httpd_db, handle_design_req}
_temp_view = {couch_mrview_http, handle_temp_view_req}
_view_cleanup = {couch_mrview_http, handle_cleanup_req}

[httpd_design_handlers]
_compact = {couch_mrview_http, handle_compact_req}
_info = {couch_mrview_http, handle_info_req}
_list = {couch_mrview_show, handle_view_list_req}
_rewrite = {couch_httpd_rewrite, handle_rewrite_req}
_show = {couch_mrview_show, handle_doc_show_req}
_update = {couch_mrview_show, handle_doc_update_req}
_view = {couch_mrview_http, handle_view_req}
_view_changes = {couch_mrview_http, handle_view_changes_req}

[uuids]
; Known algorithms:
; random - 128 bits of random awesome
Expand Down
6 changes: 1 addition & 5 deletions rel/overlay/etc/local.ini
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,8 @@
; Basic realm="server" in order to prevent you getting logged out.
; require_valid_user = false

[daemons]
; enable SSL support by uncommenting the following line and supply the PEM's below.
; the default ssl port CouchDB listens on is 6984
; httpsd = {chttpd, start_link, [https]}

[ssl]
;enable = true
;cert_file = /full/path/to/server_cert.pem
;key_file = /full/path/to/server_key.pem
;password = somepassword
Expand Down
4 changes: 3 additions & 1 deletion rel/reltool.config
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,7 @@
{copy, "files/sys.config", "releases/\{\{rel_vsn\}\}/sys.config"},
{copy, "files/vm.args", "releases/\{\{rel_vsn\}\}/vm.args"},
{template, "overlay/etc/default.ini", "etc/default.ini"},
{template, "overlay/etc/vm.args", "etc/vm.args"}
{template, "overlay/etc/vm.args", "etc/vm.args"},
{template, "files/couchdb.in", "bin/couchdb"},
{template, "files/couchdb.cmd.in", "bin/couchdb.cmd"}
]}.
1 change: 1 addition & 0 deletions src/chttpd/test/chttpd_view_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ setup() ->
TmpDb = ?tempdb(),
Addr = config:get("chttpd", "bind_address", "127.0.0.1"),
Port = mochiweb_socket_server:get(chttpd, port),
os:putenv("COUCHDB_QUERY_SERVER_JAVASCRIPT", "../../../bin/couchjs ../../../share/server/main.js"),
Url = lists:concat(["http://", Addr, ":", Port, "/", ?b2l(TmpDb)]),
create_db(Url),
Url.
Expand Down
36 changes: 36 additions & 0 deletions src/couch/src/couch.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,41 @@
ioq,
couch_stats,
hyper
]},
{env, [
{ httpd_global_handlers, [
{"/", "{couch_httpd_misc_handlers, handle_welcome_req, <<\"Welcome\">>}"},
{"favicon.ico", "{couch_httpd_misc_handlers, handle_favicon_req, \"{{prefix}}/share/www\"}"},
{"_utils", "{couch_httpd_misc_handlers, handle_utils_dir_req, \"{{prefix}}/share/www\"}"},
{"_all_dbs", "{couch_httpd_misc_handlers, handle_all_dbs_req}"},
{"_active_tasks", "{couch_httpd_misc_handlers, handle_task_status_req}"},
{"_config", "{couch_httpd_misc_handlers, handle_config_req}"},
{"_replicate", "{couch_replicator_httpd, handle_req}"},
{"_uuids", "{couch_httpd_misc_handlers, handle_uuids_req}"},
{"_stats", "{couch_stats_httpd, handle_stats_req}"},
{"_session", "{couch_httpd_auth, handle_session_req}"},
{"_plugins", "{couch_plugins_httpd, handle_req}"},
{"_system", "{chttpd_misc, handle_system_req}"}
]},
{ httpd_db_handlers, [
{"_all_docs", "{couch_mrview_http, handle_all_docs_req}"},
{"_local_docs", "{couch_mrview_http, handle_local_docs_req}"},
{"_design_docs", "{couch_mrview_http, handle_design_docs_req}"},
{"_changes", "{couch_httpd_db, handle_db_changes_req}"},
{"_compact", "{couch_httpd_db, handle_compact_req}"},
{"_design", "{couch_httpd_db, handle_design_req}"},
{"_temp_view", "{couch_mrview_http, handle_temp_view_req}"},
{"_view_cleanup", "{couch_mrview_http, handle_cleanup_req}"}
]},
{ httpd_design_handlers, [
{"_compact", "{couch_mrview_http, handle_compact_req}"},
{"_info", "{couch_mrview_http, handle_info_req}"},
{"_list", "{couch_mrview_show, handle_view_list_req}"},
{"_rewrite", "{couch_httpd_rewrite, handle_rewrite_req}"},
{"_show", "{couch_mrview_show, handle_doc_show_req}"},
{"_update", "{couch_mrview_show, handle_doc_update_req}"},
{"_view", "{couch_mrview_http, handle_view_req}"},
{"_view_changes", "{couch_mrview_http, handle_view_changes_req}"}
]}
]}
]}.
17 changes: 10 additions & 7 deletions src/couch/src/couch_httpd.erl
Original file line number Diff line number Diff line change
Expand Up @@ -104,25 +104,28 @@ start_link(Name, Options) ->
Else -> Else
end,
ok = validate_bind_address(BindAddress),
DefaultSpec = "{couch_httpd_db, handle_request}",
DefaultFun = make_arity_1_fun(
config:get("httpd", "default_handler", DefaultSpec)
),
DefaultFun = make_arity_1_fun("{couch_httpd_db, handle_request}"),

{ok, HttpdGlobalHandlers} = application:get_env(httpd_global_handlers),

UrlHandlersList = lists:map(
fun({UrlKey, SpecStr}) ->
{?l2b(UrlKey), make_arity_1_fun(SpecStr)}
end, config:get("httpd_global_handlers")),
end, HttpdGlobalHandlers),

{ok, HttpdDbHandlers} = application:get_env(httpd_db_handlers),

DbUrlHandlersList = lists:map(
fun({UrlKey, SpecStr}) ->
{?l2b(UrlKey), make_arity_2_fun(SpecStr)}
end, config:get("httpd_db_handlers")),
end, HttpdDbHandlers),

{ok, HttpdDesignHandlers} = application:get_env(httpd_design_handlers),

DesignUrlHandlersList = lists:map(
fun({UrlKey, SpecStr}) ->
{?l2b(UrlKey), make_arity_3_fun(SpecStr)}
end, config:get("httpd_design_handlers")),
end, HttpdDesignHandlers),

UrlHandlers = dict:from_list(UrlHandlersList),
DbUrlHandlers = dict:from_list(DbUrlHandlersList),
Expand Down
Loading